第一步,安装node.js,因为vue的运行是要依赖于node的npm的管理工具来实现的,官网下载,最好安装在系统盘之外的盘中。安装完成后,将安装路径加到环境变量PATH中。
第二步,在node.js的安装目录下创建两个文件夹,node_cache和node_global,然后命令行设置:设置缓存文件夹和设置全局模块存放路径。
设置完之后,会在用户目录下生成一个文件,.npmrc,如果再次执行命令,就会报错:
D:\nodejs>npm config set prefix 'D:\nodejs\node_global'
Error: EINVAL: invalid argument, mkdir 'D:\nodejs\'D:\nodejs\node_global'
TypeError: Cannot read property 'loaded' of undefined
at exit (D:\nodejs\node_modules\npm\lib\utils\error-handler.js:97:27)
at errorHandler (D:\nodejs\node_modules\npm\lib\utils\error-handler.js:215:3)
at D:\nodejs\node_modules\npm\bin\npm-cli.js:77:20
at cb (D:\nodejs\node_modules\npm\lib\npm.js:225:22)
at D:\nodejs\node_modules\npm\lib\npm.js:263:24
at D:\nodejs\node_modules\npm\lib\config\core.js:83:7
at Array.forEach (<anonymous>)
at D:\nodejs\node_modules\npm\lib\config\core.js:82:13
at f (D:\nodejs\node_modules\npm\node_modules\once\once.js:25:25)
at afterExtras (D:\nodejs\node_modules\npm\lib\config\core.js:173:20)
D:\nodejs\node_modules\npm\lib\utils\error-handler.js:97
var doExit = npm.config.loaded ? npm.config.get('_exit') : true
^
TypeError: Cannot read property 'loaded' of undefined
at exit (D:\nodejs\node_modules\[4mnpm[24m\lib\utils\error-handler.js:97:27)
at process.errorHandler (D:\nodejs\node_modules\[4mnpm[24m\lib\utils\error-h
[90m at process.emit (events.js:209:13)[39m
[90m at process._fatalException (internal/process/execution.js:150:25)[39m
Error: EINVAL: invalid argument, mkdir 'D:\nodejs\'D:\nodejs\node_global'
TypeError: Cannot read property 'loaded' of undefined
at exit (D:\nodejs\node_modules\npm\lib\utils\error-handler.js:97:27)
at errorHandler (D:\nodejs\node_modules\npm\lib\utils\error-handler.js:215:3)
at D:\nodejs\node_modules\npm\bin\npm-cli.js:77:20
at cb (D:\nodejs\node_modules\npm\lib\npm.js:225:22)
at D:\nodejs\node_modules\npm\lib\npm.js:263:24
at D:\nodejs\node_modules\npm\lib\config\core.js:83:7
at Array.forEach (<anonymous>)
at D:\nodejs\node_modules\npm\lib\config\core.js:82:13
at f (D:\nodejs\node_modules\npm\node_modules\once\once.js:25:2