问题1: 配置环境变量
首先,在nodejs安装的目录下新建两个文件夹
其次,新建系统变量
变量名NODE_PATH
变量值D:\Program Files\nodejs\node_modules
, 这里写你安装之后node_modules
所在的路径
然后,在用户变量的Path中将`改为
D:\Program Files\nodejs\node_global(此处是
node_global`所在的路径)
最后,在系统变量的Path中新建两个变量,D:\Program Files\nodejs\
(nodejs根目录的路径,需要根据自己安装的路径来配)和%NODE_PATH%
问题2:
cmd命令窗输入`npm -v时,遇到以下错误
原因: C:\Users\xxx (xxx是用户名)这个路径下,有.npmrc文件,打开我发现最后一行重复了,把它删除即可。
问题3:
cmd命令窗输入npm install -g cnpm --registry=https://registry.npm.taobao.org
配置全局淘宝镜像时,遇到以下错误
npm ERR! code EPERM
npm ERR! syscall mkdir
npm ERR! path D:\Program Files\nodejs\node_cache\_cacache
npm ERR! errno -4048
npm ERR! Error: EPERM: operation not permitted, mkdir 'D:\Program Files\nodejs\node_cache\_cacache'
npm ERR! [OperationalError: EPERM: operation not permitted, mkdir 'D:\Program Files\nodejs\node_cache\_cacache'] {
npm ERR! cause: [Error: EPERM: operation not permitted, mkdir 'D:\Program Files\nodejs\node_cache\_cacache'] {
npm ERR! errno: -4048,
npm ERR! code: 'EPERM',
npm ERR! syscall: 'mkdir',
npm ERR! path: 'D:\\Program Files\\nodejs\\node_cache\\_cacache'
npm ERR! },
npm ERR! isOperational: true,
npm ERR! errno: -4048,
npm ERR! code: 'EPERM',
npm ERR! syscall: 'mkdir',
npm ERR! path: 'D:\\Program Files\\nodejs\\node_cache\\_cacache'
npm ERR! }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It's possible that the file was already in use (by a text editor or antivirus),
npm ERR! or that you lack permissions to access it.
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.
原因: 看错误的最后一行,没有以管理员身份运行cmd