博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
全局安装gulp 报错问题解决
阅读量:5031 次
发布时间:2019-06-12

本文共 3667 字,大约阅读时间需要 12 分钟。

sudo npm install --global gulp 报错

 

 

node-pre-gyp WARN Using needle for node-pre-gyp https download node-pre-gyp WARN Pre-built binaries not installable for fsevents@1.2.8 and node@10.15.3 (node-v64 ABI, unknown) (falling back to source compile with node-gyp) node-pre-gyp WARN Hit error EACCES: permission denied, mkdir '/usr/local/lib/node_modules/gulp/node_modules/fsevents/lib' gyp WARN EACCES user "root" does not have permission to access the dev dir "/Users/liruinan/.node-gyp/10.15.3"gyp WARN EACCES attempting to reinstall using temporary dev dir "/usr/local/lib/node_modules/gulp/node_modules/fsevents/.node-gyp"gyp WARN install got an error, rolling back installgyp WARN install got an error, rolling back installgyp ERR! configure error gyp ERR! stack Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/gulp/node_modules/fsevents/.node-gyp'gyp ERR! System Darwin 16.1.0gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "configure" "--fallback-to-build" "--module=/usr/local/lib/node_modules/gulp/node_modules/fsevents/lib/binding/Release/node-v64-darwin-x64/fse.node" "--module_name=fse" "--module_path=/usr/local/lib/node_modules/gulp/node_modules/fsevents/lib/binding/Release/node-v64-darwin-x64" "--napi_version=3" "--node_abi_napi=napi" "--napi_build_version=0" "--node_napi_label=node-v64"gyp ERR! cwd /usr/local/lib/node_modules/gulp/node_modules/fseventsgyp ERR! node -v v10.15.3gyp ERR! node-gyp -v v3.8.0gyp ERR! not ok node-pre-gyp ERR! build error node-pre-gyp ERR! stack Error: Failed to execute '/usr/local/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/usr/local/lib/node_modules/gulp/node_modules/fsevents/lib/binding/Release/node-v64-darwin-x64/fse.node --module_name=fse --module_path=/usr/local/lib/node_modules/gulp/node_modules/fsevents/lib/binding/Release/node-v64-darwin-x64 --napi_version=3 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v64' (1)node-pre-gyp ERR! stack     at ChildProcess.
(/usr/local/lib/node_modules/gulp/node_modules/fsevents/node_modules/node-pre-gyp/lib/util/compile.js:83:29)node-pre-gyp ERR! stack at ChildProcess.emit (events.js:189:13)node-pre-gyp ERR! stack at maybeClose (internal/child_process.js:970:16)node-pre-gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)node-pre-gyp ERR! System Darwin 16.1.0node-pre-gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/gulp/node_modules/fsevents/node_modules/node-pre-gyp/bin/node-pre-gyp" "install" "--fallback-to-build"node-pre-gyp ERR! cwd /usr/local/lib/node_modules/gulp/node_modules/fseventsnode-pre-gyp ERR! node -v v10.15.3node-pre-gyp ERR! node-pre-gyp -v v0.12.0node-pre-gyp ERR! not ok

解决方法 

npm install 添加参数 --unsafe-perm

sudo npm install --global gulp --unsafe-perm

 

理由

If npm detects it is running as root it drops to a non-privileged user which then doesn‘t have permissions to write to /root/.node-gyp.

##如果NPM检测到它以根用户身份运行,它将下降到一个没有权限写入/root/.node gyp的非特权用户。

The  --unsafe-perm option stops it from changing user.

nvm doesn‘t have this problem when not using sudo because it stores everything under the current users‘ home directory.

##NVM在不使用sudo时没有这个问题,因为它将所有内容存储在当前用户的主目录下。

 

看官方文档的解释 

unsafe-perm

Default: false if running as root, true otherwise
Type: Boolean
Set to true to suppress the UID/GID switching when running package scripts.

##设置为true可在运行包脚本时抑制uid/gid切换。

If set explicitly to false, then installing as a non-root user will fail.

 

 

转载于:https://www.cnblogs.com/haibiancao/p/10756473.html

你可能感兴趣的文章
【Github教程】史上最全github使用方法:github入门到精通
查看>>
抽象工厂模式(Abstract Factory)
查看>>
luogu1373 小a和uim之大逃离 (dp)
查看>>
Redis的Pub/Sub客户端实现
查看>>
SQL日常问题和技巧——持续更新
查看>>
springMVC入门(一)------springMVC基本概念与安装
查看>>
Sam做题记录
查看>>
[bzoj] 2453 维护数列 || 单点修改分块
查看>>
IIS版本变迁
查看>>
BZOJ3884: 上帝与集合的正确用法 拓展欧拉定理
查看>>
mybatis09--自连接一对多查询
查看>>
myeclipse10添加jQuery自动提示的方法
查看>>
【eclipse jar包】在编写java代码时,为方便编程,常常会引用别人已经实现的方法,通常会封装成jar包,我们在编写时,只需引入到Eclipse中即可。...
查看>>
视频监控 封装[PlayCtrl.dll]的API
查看>>
软件工程APP进度更新
查看>>
Python 使用正则替换 re.sub
查看>>
CTF中那些脑洞大开的编码和加密
查看>>
简化工作流程 10款必备的HTML5开发工具
查看>>
c++ 调用外部程序exe-ShellExecuteEx
查看>>
Java进击C#——语法之知识点的改进
查看>>