我运行 npm install lodash, 但它抛出 错误:EACCES:权限被拒绝 错误。我知道这是权限问题,但据我所知,本地安装节点模块不需要sudo权限。如果我使用sudo运行它,它将安装在〜/ node_modules文件夹中。 drwxrwxr-x 是现有文件夹的文件许可权。我不知道可能出了什么问题。
下面是错误消息。
npm ERR! tar.unpack untar error /home/rupesh/.npm/lodash/4.13.1/package.tgz npm ERR! Linux 3.13.0-88-generic npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "lodash" npm ERR! node v4.3.1 npm ERR! npm v2.14.12 npm ERR! path /home/rupesh/node_modules/lodash npm ERR! code EACCES npm ERR! errno -13 npm ERR! syscall mkdir npm ERR! Error: EACCES: permission denied, mkdir '/home/rupesh/node_modules/lodash' npm ERR! at Error (native) npm ERR! { [Error: EACCES: permission denied, mkdir '/home/rupesh/node_modules/lodash'] npm ERR! errno: -13, npm ERR! code: 'EACCES', npm ERR! syscall: 'mkdir', npm ERR! path: '/home/rupesh/node_modules/lodash', npm ERR! fstream_type: 'Directory', npm ERR! fstream_path: '/home/rupesh/node_modules/lodash', npm ERR! fstream_class: 'DirWriter', npm ERR! fstream_stack: npm ERR! [ '/usr/local/lib/node_modules/npm/node_modules/fstream/lib/dir-writer.js:35:25', npm ERR! '/usr/local/lib/node_modules/npm/node_modules/mkdirp/index.js:47:53', npm ERR! 'FSReqWrap.oncomplete (fs.js:82:15)' ] } 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! /home/rupesh/Desktop/es6/npm-debug.log
使用 npm init 创建 package.json 解决了我的问题。 __