Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/npm/2.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安装”`_Node.js_Npm_Sudo - Fatal编程技术网

Node.js 我得到;“拒绝访问”;关于“npm安装”`

Node.js 我得到;“拒绝访问”;关于“npm安装”`,node.js,npm,sudo,Node.js,Npm,Sudo,我正在安装一个新项目,在npm安装时我得到以下错误。 我试过这个解决办法,但没有什么不同。在终端中输入这些行不会产生任何输出,npm install之后会导致相同的错误。 你知道怎么解决这个问题吗 Unhandled rejection Error: EACCES: permission denied, open '/home/user/.npm/_cacache/tmp/5134a7c3'd in 126ms Unhandled rejection Error: EACCES: permis

我正在安装一个新项目,在
npm安装时
我得到以下错误。 我试过这个解决办法,但没有什么不同。在终端中输入这些行不会产生任何输出,
npm install
之后会导致相同的错误。 你知道怎么解决这个问题吗

Unhandled rejection Error: EACCES: permission denied, open '/home/user/.npm/_cacache/tmp/5134a7c3'd in 126ms

Unhandled rejection Error: EACCES: permission denied, open '/home/user/.npm/_cacache/tmp/fcf123f8'^1.1.7 fetched in 96ms

Unhandled rejection Error: EACCES: permission denied, open '/home/user/.npm/_cacache/tmp/f8a35f38'd in 39ms

Unhandled rejection Error: EACCES: permission denied, open '/home/user/.npm/_cacache/tmp/3914ffcc'4ms

Unhandled rejection Error: EACCES: permission denied, open '/home/user/.npm/_cacache/tmp/98bb7e0d'tched in 65ms

Unhandled rejection Error: EACCES: permission denied, open '/home/user/.npm/_cacache/tmp/5196be2e'63ms

Unhandled rejection Error: EACCES: permission denied, open '/home/user/.npm/_cacache/tmp/1cf3fdde'fetched in 394ms

npm WARN checkPermissions Missing write access to /projects/user-portal/node_modules
npm WARN checkPermissions Missing write access to /projects/user-portal/node_modules/@google-cloud
npm WARN bookshelf@0.10.4 requires a peer of knex@>=0.6.10 <=0.13.0 but none is installed. You must install peer dependencies yourself.
npm WARN bootstrap@4.3.1 requires a peer of jquery@1.9.1 - 3 but none is installed. You must install peer dependencies yourself.
npm WARN bootstrap@4.3.1 requires a peer of popper.js@^1.14.7 but none is installed. You must install peer dependencies yourself.
npm WARN portal@1.0.0 license should be a valid SPDX license expression

npm ERR! path /projects/user-portal/node_modules
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall access
npm ERR! Error: EACCES: permission denied, access '/projects/user-portal/node_modules'
npm ERR!  { Error: EACCES: permission denied, access '/projects/user-portal/node_modules'
npm ERR!   stack: 'Error: EACCES: permission denied, access \'/projects/user-portal/node_modules\'',
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'access',
npm ERR!   path: '/projects/user-portal/node_modules' }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator (though this is not recommended).

我只是超级用户做的:

sudo npm install -g
全球的东西

只是:

sudo chown -R [user]:[user] /projects/ 
或者创建一个“项目”组,将自己加入该组,并使该组拥有该组

尽管如此,如果我是你,我会像@agtabesh建议的那样将你的项目移动到你的主目录。

首先运行这行:

sudo chown -R $USER /usr/local/lib/node_modules
说明:


这两个命令的结果是什么
whoami
ls-la/projects
。最好在主目录中创建项目。谢谢,
whoami
返回
user
。和
ls-la/projects
返回:
total 4
drwxr-xr-x 3用户root 25 Jul 4 20:46.
drwxr-xr-x 22 root 295 Jul 4 21:45.
drwxr-xr-x 18用户用户4096 Jul 4 21:18用户门户我正在使用IDE(Codenvy)这就是为什么项目位于工作区的子文件夹中。是否安装了make?快速检查将是
make-v
啊,它确实不是,也不是在运行!非常感谢。谢谢,我用这个建议的结果更新了OP。我不喜欢在这里使用sudo,不幸的是,在Codenvy上无法将项目移动到主目录。欢迎使用SO。请在答案中直接添加一些描述
sudo chown -R $USER /usr/local/lib/node_modules