NPM全局安装依赖权限报错Error: EACCES: permission denied

最近在安装electron-forge的时候报错如下:

?  ~ sudo npm install -g electron-forge
npm WARN deprecated [email protected]: [email protected]<3 is no longer maintained and not recommended for usage due to the number of issues. Please, upgrade your dependencies to the actual version of [email protected]
npm WARN deprecated [email protected]: cross-spawn no longer requires a build toolchain, use it instead
npm WARN deprecated [email protected]: wrench.js is deprecated! You should check out fs-extra (https://github.com/jprichardson/node-fs-extra) for any operations you were using wrench for. Thanks for all the usage over the years.
npm WARN deprecated [email protected]: This module relies on Node.js‘s internals and will break at some point. Do not use it, and update to [email protected]
npm WARN deprecated [email protected]: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
/usr/local/bin/electron-forge-vscode-win -> /usr/local/lib/node_modules/electron-forge/script/vscode.cmd
/usr/local/bin/forge -> /usr/local/lib/node_modules/electron-forge/dist/electron-forge.js
/usr/local/bin/electron-forge -> /usr/local/lib/node_modules/electron-forge/dist/electron-forge.js
/usr/local/bin/electron-forge-vscode-nix -> /usr/local/lib/node_modules/electron-forge/script/vscode.sh

> [email protected] install /usr/local/lib/node_modules/electron-forge/node_modules/fs-xattr
> node-gyp rebuild

gyp WARN EACCES current user ("nobody") does not have permission to access the dev dir "/Users/mac/Library/Caches/node-gyp/10.18.0"
gyp WARN EACCES attempting to reinstall using temporary dev dir "/usr/local/lib/node_modules/electron-forge/node_modules/fs-xattr/.node-gyp"
gyp WARN install got an error, rolling back install
gyp WARN install got an error, rolling back install
gyp ERR! configure error
gyp ERR! stack Error: EACCES: permission denied, mkdir ‘/usr/local/lib/node_modules/electron-forge/node_modules/fs-xattr/.node-gyp‘
gyp ERR! System Darwin 19.2.0
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /usr/local/lib/node_modules/electron-forge/node_modules/fs-xattr
gyp ERR! node -v v10.18.0
gyp ERR! node-gyp -v v5.0.5
gyp ERR! not ok

> [email protected] install /usr/local/lib/node_modules/electron-forge/node_modules/macos-alias
> node-gyp rebuild

gyp WARN EACCES current user ("nobody") does not have permission to access the dev dir "/Users/mac/Library/Caches/node-gyp/10.18.0"
gyp WARN EACCES attempting to reinstall using temporary dev dir "/usr/local/lib/node_modules/electron-forge/node_modules/macos-alias/.node-gyp"
gyp WARN install got an error, rolling back install
gyp WARN install got an error, rolling back install
gyp ERR! configure error
gyp ERR! stack Error: EACCES: permission denied, mkdir ‘/usr/local/lib/node_modules/electron-forge/node_modules/macos-alias/.node-gyp‘
gyp ERR! System Darwin 19.2.0
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /usr/local/lib/node_modules/electron-forge/node_modules/macos-alias
gyp ERR! node -v v10.18.0
gyp ERR! node-gyp -v v5.0.5
gyp ERR! not ok

> [email protected] install /usr/local/lib/node_modules/electron-forge
> node tabtab-install.js

User shell sh not supported, skipping completion install
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/electron-forge/node_modules/fs-xattr):
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] install: `node-gyp rebuild`
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: Exit status 1
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/electron-forge/node_modules/macos-alias):
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] install: `node-gyp rebuild`
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: Exit status 1

+ [email protected]
added 4 packages from 2 contributors and updated 1 package in 19.963s

由上述报错可以看出,很明细是权限问题,但是明明加上了sudo提权啊?为啥还报错呢?而且前几天在Windows中使用CMD管理员权限安装也会报同样的错误。

那么可以使用如下参数进行安装:

sudo npm install -g electron-forge --unsafe-perm

可能是系统检测到安全性问题了。

原文地址:https://blog.51cto.com/xvjunjie/2464880

时间: 2024-10-17 16:32:20

NPM全局安装依赖权限报错Error: EACCES: permission denied的相关文章

npm install报错 Error: EACCES: permission denied

报错内容 Unable to save binary /root/packageadmin/spring-boot-admin-2.1.6/spring-boot-admin-server-ui/node_modules/node-sass/vendor/linux-x64-64 : { Error: EACCES: permission denied, mkdir '/root/packageadmin/spring-boot-admin-2.1.6/spring-boot-admin-ser

node-sass安装失败的问题 stack Error: EACCES: permission denied, mkdir

最近在自己的项目中遇到了一个node-sass 包安装的问题,问题如下 当我 sudo npm i 会出现下面这段错误信息,我试了修改权限和修改包的版本后还是没有能够解决,最后google 终于解决了,这里记下问题的原因和解决办法 gyp verb build dir attempting to create "build" dir: /工作:学习/github/react-view/node_modules/node-sass/build gyp ERR! configure err

【vue】vue项目中服务器跑不起来 报错 listen EACCES: permission denied 3000--hot

报错截图如下 1.解决过程: 一开始只在vscode终端看到了最先面的报错信息,如下图: 看不出个所以然 网络搜索一番后,有如下类似问题的解决方案 npm cache clean --force 手动删除node-module文件夹 npm i npm run dev 结果还是不行,着急之际,滚动了一下鼠标 看到了完整的报错信息 发现是端口号不对 把3000选中改成了3001 还是同样的报错 正无奈 发现原来是端口号跟 --hot之间少了一个空格....... 鬼知道我拷贝之前的可以完好运行的项

安装python模块报错 error: command &#39;gcc&#39; failed with exit status 1

最近在安装paramiko模块的时候,总是报错:error: command 'gcc' failed with exit status 1,一开始比较挠头.找了蛮多资料,说的大多都是说缺少Python-devel 包,然而并不是! 最后蛮费劲的找到了一遍短小但就是正确的博文:http://blog.csdn.net/fenglifeng1987/article/details/38057193 —————————————————————— 解决方法: 安装:yum install gcc li

一看便知linux下mysql报错ERROR 1044: Access denied for user: &#39;@localhost&#39; to database &#39;mysql&#39;

错误信息:ERROR 1044: Access denied for user: '@localhost' to database 'mysql' linux下解决方案: mysql> use mysql ERROR 1044 (42000): Access denied for user 'root'@'localhost' to database 'mysql' mysql> exit Bye [[email protected] ~]# service mysqld stop如果该命令不

mac 安装polymer cli Error: EACCES: permission denied, mkdir &#39;/usr/local/lib/node_modules/polymer-cli/node_modules/wd/build&#39;

安装的时候根据说明,需要使用npm install -g polymer-cli命令,但是一直提示没有权限, 后来增加sudo后提示如下, Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/polymer-cli/node_modules/wd/build' at Object.fs.mkdirSync (fs.js:905:18) at sync (/usr/local/lib/node_modules/p

Unhandled rejection Error: EACCES: permission denied, open &#39;

npm  i 突然罢工了.很慌---- 就问你怕不怕- 使用npm  i  竟然不能正常的工作--- 解决方案如下: 这行代码可以轻松解决这个问题!!! Unhandled rejection Error: EACCES: permission denied, open ' 原文地址:https://www.cnblogs.com/yaogengzhu/p/10797790.html

安装centos6.10时,安装完成重启报错error 15,file not found

今天在一台老式联想服务器上安装centos6.10操作系统,安装完成,重启时,出现报错 error 15, file not found...... 在百度上搜索到进grub编辑,可还是无法解决问题,仍然file not found: 后来我将服务器硬盘格式化了,然后再正常安装系统,结果就能正常启动了,稀里糊涂的就解决了: 到现在还有疑惑,如果有哪位大神路过请解释一下,感激不尽 原文地址:https://www.cnblogs.com/new-journey/p/12039017.html

MAC系统npm安装依赖,报错npm ERR! code ECONNREFUSED

在开发过程中,安装npm依赖包遇到这个报错问题,如下图所示: 查了很多资料,尝试了很多方法都不奏效,最后尝试使用cnpm安装,一分钟搞定,如果有更好的方法,可以留言交流哦~~ 解决方案:Mac安装淘宝镜像cnpm(参考https://www.jianshu.com/p/c43725f7606e), 具体步骤: 安装cnpm需要一个最高权限: sudo npm install -g cnpm --registry=https://registry.npm.taobao.org --verbose