Npm install failed with “cannot run in wd”
生活随笔
收集整理的這篇文章主要介紹了
Npm install failed with “cannot run in wd”
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
Linux環境下,root賬戶,安裝某些npm包的時候報下面的錯誤,例如安裝grunt-contrib-imagemin時:
Error: EACCES, mkdir '/usr/local/lib/node_modules/coffee-script' npm ERR! { [Error: EACCES, mkdir '/usr/local/lib/node_modules/coffee-script'] npm ERR! errno: 3, npm ERR! code: 'EACCES', npm ERR! path: '/usr/local/lib/node_modules/coffee-script', npm ERR! fstream_type: 'Directory', npm ERR! fstream_path: '/usr/local/lib/node_modules/coffee-script', npm ERR! fstream_class: 'DirWriter', npm ERR! fstream_stack: npm ERR! [ 'DirWriter._create (/usr/local/lib/node_modules/npm/node_modules/fstream/lib/dir-writer.js:36:23)', npm ERR! '/usr/local/lib/node_modules/npm/node_modules/mkdirp/index.js:37:53', npm ERR! 'Object.oncomplete (fs.js:297:15)' ] } npm ERR! npm ERR! Please try running this command again as root/Administrator.解決辦法如下:
具體內容可以看下面這兩個頁面的介紹:
https://docs.npmjs.com/misc/scripts#user
https://docs.npmjs.com/getting-started/fixing-npm-permissions
大致意思就是說:如果npm是在root賬戶下執行的話,它會將uid改成當前賬戶,或者uid的值從user配置文件中獲取,而默認情況下uid的值為nobody。所以在root賬戶下運行npm install時需要將unsafe-perm選項加上。
更多專業前端知識,請上 【猿2048】www.mk2048.com
總結
以上是生活随笔為你收集整理的Npm install failed with “cannot run in wd”的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 深入研究ES6 Generators
- 下一篇: 使用aggregate在MongoDB中