今天学习一个项目需要用npm安装一些模块,然后都发现安装错误
提示
npm ERR! Darwin 14.5.0 npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "-g" "n" npm ERR! node v6.9.5 npm ERR! npm v3.10.10 npm ERR! path /usr/local/lib/node_modules npm ERR! code EACCES npm ERR! errno -13 npm ERR! syscall access npm ERR! Error: EACCES: permission denied, access '/usr/local/lib/node_modules' npm ERR! at Error (native) npm ERR! { Error: EACCES: permission denied, access '/usr/local/lib/node_modules' npm ERR! at Error (native) npm ERR! errno: -13, npm ERR! code: 'EACCES', npm ERR! syscall: 'access', npm ERR! path: '/usr/local/lib/node_modules' } 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! /Users/liyiting/IdeaProjects/webAppReader/npm-debug.log经过参考各位大神的文章有以下几种解决方式:
1.重新安装更新版的nodeJS(浏览官网发现已经安装最新版本)
2.在指令前加sudo (sudo npm install 报错)
3.有可能是因为资源被墙了,所以先安装nrm模块来切换npm源(报错)
4.先安装管理nodejs版本的模块 n,再检查是否有更新的稳定版(最后用的这种)
顺利安装上了n模块
npm install -g n npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules /usr/local/lib └── n@2.1.4 然后升级到最新稳定版 n stable install : node-v7.4.0 mkdir : /usr/local/n/versions/node/7.4.0 fetch : https://nodejs.org/dist/v7.4.0/node-v7.4.0-darwin-x64.tar.gz ############################ 38.9%
安装到一半进度条不动了,查到一篇文章惊恐地关闭了安装窗口[文章5]
To be continue..
