npm install express -g 报错

时间:2024-03-19 08:02:48

node.js环境配置完后,安装个module测试下,打开cmd窗口,输入npm install express -g 报错如下

C:\Users\Administrator>npm install express -g
npm ERR! Windows_NT 10.0.15063
npm ERR! argv “C:\Program Files\nodejs\node.exe” “C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js” “install” “express” “-g”
npm ERR! node v4.4.3
npm ERR! npm v2.15.1
npm ERR! path C:\Program Files\nodejs\node_cache\express
npm ERR! code EPERM
npm ERR! errno -4048
npm ERR! syscall mkdir

npm ERR! Error: EPERM: operation not permitted, mkdir ‘C:\Program Files\nodejs\node_cache\express’
npm ERR! at Error (native)
npm ERR! { [Error: EPERM: operation not permitted, mkdir ‘C:\Program Files\nodejs\node_cache\express’]
npm ERR! errno: -4048,
npm ERR! code: ‘EPERM’,
npm ERR! syscall: ‘mkdir’,
npm ERR! path: ‘C:\Program Files\nodejs\node_cache\express’ }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.

npm ERR! Please include the following file with any support request:
npm ERR! C:\Users\Administrator\npm-debug.log

解决方法:
开始菜单——搜索
npm install express -g 报错
输入命令提示符npm install express -g 报错
鼠标放命令提示符右键选择以管理员身份运行
然后再输一次npm install express -g 成功