Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/37.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js npm安装-g不';我什么都干不了_Node.js_Npm - Fatal编程技术网

Node.js npm安装-g不';我什么都干不了

Node.js npm安装-g不';我什么都干不了,node.js,npm,Node.js,Npm,我试图在终端中使用以下命令使用npm安装gatsbyjs:npm install-g gatsby cli。我得到一个警告和一堆错误: npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules npm ERR! path /usr/local/lib/node_modules npm ERR! code EACCES npm ERR! errno -13 npm ERR! syscall acces

我试图在终端中使用以下命令使用npm安装gatsbyjs:npm install-g gatsby cli。我得到一个警告和一堆错误:

npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules
npm ERR! path /usr/local/lib/node_modules
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall access
npm ERR! Error: EACCES: permission denied, access '/usr/local/lib/node_modules'
npm ERR!  { Error: EACCES: permission denied, access '/usr/local/lib/node_modules'
npm ERR!   stack: 'Error: EACCES: permission denied, access \'/usr/local/lib/node_modules\'',
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'access',
npm ERR!   path: '/usr/local/lib/node_modules' }
npm ERR! 
npm ERR! Please try running this command again as root/Administrator.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/simanshrestha/.npm/_logs/2018-07-07T22_48_08_615Z-debug.log
我尝试重新安装Node.js并使用:npm install更新npmnpm@latest-g,但只收到一堆检查权限警告和以下错误:

npm ERR! path /usr/local/lib/node_modules/npm/node_modules/cacache/node_modules/ssri
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall access
npm ERR! Error: EACCES: permission denied, access '/usr/local/lib/node_modules/npm/node_modules/cacache/node_modules/ssri'
npm ERR!  { Error: EACCES: permission denied, access '/usr/local/lib/node_modules/npm/node_modules/cacache/node_modules/ssri'
npm ERR!   stack: 'Error: EACCES: permission denied, access \'/usr/local/lib/node_modules/npm/node_modules/cacache/node_modules/ssri\'',
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'access',
npm ERR!   path: '/usr/local/lib/node_modules/npm/node_modules/cacache/node_modules/ssri' }
npm ERR! 
npm ERR! Please try running this command again as root/Administrator.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/simanshrestha/.npm/_logs/2018-07-07T22_49_59_092Z-debug.log
我一直在尝试修复权限错误,但我被卡住了(我对这东西真的很陌生)


编辑:我不想使用sudo,因为我已经看到它可能会把多个论坛的事情搞砸。

您应该以管理员身份运行npm install-g


正如控制台所说。

您的问题有3种可能的解决方案,即基本上没有root访问权限,无法将模块安装到root
node\u模块
dir:

  • 运行
    sudo npm i-gpackage@latest
    。这将解决您的问题,但每次都会请求root密码

  • 更改默认的全局模块文件夹,如
    npm config set prefix

  • 安装并用于管理
    节点
    npm
    ,它在本地用户中随附了正确设置的文件夹结构。因此不需要额外的权限,也不需要修改配置前缀


  • 该错误已提示可能的原因,
    请以root/Administrator身份再次尝试运行此命令