npm安装报错:Error: EACCES: permission denied
报错如下:
sudo npm i webpack -g
/Users/xesfe/.npm-global/bin/webpack -> /Users/xesfe/.npm-global/lib/node_modules/webpack/bin/webpack.js
# System-wide .profile for sh(1) > fsevents@1.2.11 install /Users/xesfe/.npm-global/lib/node_modules/webpack/node_modules/fsevents
> node-gyp rebuild gyp ERR! configure error
gyp ERR! stack Error: EACCES: permission denied, mkdir '/Users/xesfe/.npm-global/lib/node_modules/webpack/node_modules/fsevents/build'
gyp ERR! System Darwin 19.2.0
gyp ERR! command "/Users/xesfe/.nvm/versions/node/v10.16.2/bin/node" "/Users/xesfe/.nvm/versions/node/v10.16.2/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/xesfe/.npm-global/lib/node_modules/webpack/node_modules/fsevents
gyp ERR! node -v v10.16.2
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.11 (node_modules/webpack/node_modules/fsevents):
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.11 install: `node-gyp rebuild`
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: Exit status 1 + webpack@4.41.4
updated 1 package in 22.243s
方案1:
npm install --unsafe-perm=true --allow-root -g nodeppt
在安装的时候一直报错nodeppt,通过查资料添加--unsafe-perm=true --allow-root,可以解决问题,git上issue:https://github.com/npm/npm/issues/17268,这方案貌似不是那么的优雅,因此寻找第二种方案。
方案2
1、建立全局文件夹配置
mkdir ~/npm-global npm config set prefix '~/npm-global'
ps:在mac下不要建以点(.)开头的配置文件,否则还是解决不了。
2、修改环境变量
vi /etc/profile
如果文件是只读的,改一下文件的读写权限
sudo chmod 777 /etc/profile
在/etc/profile追加
# npm配置
export PATH=~/npm-global/bin:$PATH
3、激活环境变量配置
source /etc/profile
4、再次按装
i webpack -g
/Users/xesfe/npm-config/bin/webpack -> /Users/xesfe/npm-config/lib/node_modules/webpack/bin/webpack.js > fsevents@1.2.11 install /Users/xesfe/npm-config/lib/node_modules/webpack/node_modules/fsevents
> node-gyp rebuild SOLINK_MODULE(target) Release/.node
CXX(target) Release/obj.target/fse/fsevents.o
SOLINK_MODULE(target) Release/fse.node
+ webpack@4.41.4
5、如果你执行webpack 发现
zsh: command not found: webpack
那添加到环境变量就可以了。
执行以下操作:
vi .bash_profile
在.bash_profile添加
export NPM_CONFIG=~/npm-config
export PATH=$PATH:$NPM_CONFIG/bin
执行以下命令,让环境变量生效。
source .bash_profile
OK,完美解决权限不够的问题。
参考:
https://www.jianshu.com/p/7192b336c6cd
npm安装报错:Error: EACCES: permission denied的更多相关文章
- npm安装node-sass失败,EACCES: permission denied
增加--unsafe-perm,即 sudo npm install node-sass --unsafe-perm --save-dev 成功安装node-sass
- npm install 报错,提示`gyp ERR! stack Error: EACCES: permission denied` 解决方法
m install 报错,提示gyp ERR! stack Error: EACCES: permission denied 猜测可能是因为没有权限读写,ls -la看下文件权限设置情况 [root@ ...
- mac上安装webpack报错解决方法Hit error EACCES: permission denied, mkdir '/usr/local/lib/node_modules/webpack
node-pre-gyp WARN Using needle for node-pre-gyp https download node-pre-gyp WARN Pre-built binaries ...
- npm install Error: EACCES: permission denied, mkdir
今天研究Electron的时候,全局安装运行 npm install electron -g时侯,报下面的错误: Error: EACCES: permission denied, mkdir '/U ...
- fastadmin安装定时插件报错 ZipArchive::extractTo(): Permission denied
环境linux上直接安装 如果你是在win开发号直接部署的应该是没问题 我是直接在linux安装的 这几天研了下fastadmin 想用他的定时可是在使用的时候报错 ZipArchive::e ...
- Error: EACCES: permission denied, mkdir '......node-sass/build'错误解决方案
安装node-sass时出现一下错误: gyp ERR! configure error gyp ERR! stack Error: EACCES: permission denied, mkdir ...
- Error: EACCES: permission denied, symlink
环境说明 ganiks@ganiks-ubuntu-trusty-64:/ganiks/parse-server$ npm -v 6.5.0 ganiks@ganiks-ubuntu-trusty-6 ...
- npm install 时出现的 EACCES: permission denied 错误的可能有效的解决方案
最近我开始接触手机 app 的编写,公司用到了 Nativescript.当我下载了公司的项目后,在配置时出现了不少的问题,其中出现概率最高的就是 EACCES: permission denied ...
- npm install 报错 error Unexpected end of JSON input while parsing near '...sShrinkwrap":false,"d' 解决办法
npm install 报错 : error Unexpected end of JSON input while parsing near '...sShrinkwrap":false,& ...
随机推荐
- k3 cloud中提示总账期末结账提示过滤条件太长,请修改此过滤条件
k3 cloud中提示总账期末结账提示过滤条件太长,请修改此过滤条件,如下图所示: 处理方法: 请尝试系统配置文件common.config中将如附件所示的参数值改大,建议值为2000,并在系统清理缓 ...
- 20180209-xml模块
xml的用法操作如下: xml格式如下: <?xml version="1.0"?> <data> <country name="Liech ...
- swagger集成到springBoot 项目中
1 pom 文件加包依赖 <dependency> <groupId>io.springfox</groupId> <artifactId>spring ...
- Sass函数:数字函数-round()函数
round() 函数可以将一个数四舍五入为一个最接近的整数: >> round(12.3) 12 >> round(12.5) 13 >> round(1.4999 ...
- Linux的运行级别和设置开机启动服务的方式
Linux的运行级别 什么是运行级别呢?简单点来说,运行级别就是操作系统当前正在运行的功能级别.级别是从0到6,具有不同的功能.这些级别定义在/ect/inittab文件中.这个文件是init程序寻找 ...
- 唐太宗灵州勒石 TANGTAIZONGLINZHOULESHI
唐太宗灵州勒石 唐贞观二十年(646年),在唐军和回纥部落联合打败突厥薛延陀部后,原归附薛延陀部的回纥.拔野古.斛薛等部族,越过贺兰山,进入了今宁夏的银川.吴忠一带地区.这些总族向唐朝提出,愿意臣服唐 ...
- webRTC脱坑笔记(三)— webRTC API之RTCPeerConnection
RTCPeerConnection API是每个浏览器之间点对点连接的核心,RTCPeerConnection是WebRTC组件,用于处理对等体之间流数据的稳定和有效通信. RTCPeerConnec ...
- Ubuntu查找软件命令
查找软件: apt-cache search <your search item>
- cocos2D-X 线程注意事项
{ 在子线程种是无法创建纹理的,也就是精灵 }
- python使用HTMLTestRunner.py生成测试报告
这里我使用的是python selenium webdriver环境,浏览器驱动安装见selenium 1.下载HTMLTestRunner.py:http://tungwaiyip.info/sof ...