简体   繁体   English

如何在 AWS CloudShell 中安装 npm?

[英]How to npm install in AWS CloudShell?

I'm trying to install an npm package in the new AWS CloudShell (comes with pre-configured Node.js support ) - but I'm getting a EACCESS error.我正在尝试在新的 AWS CloudShell 中安装 npm package(带有预配置的 Node.js 支持) - 但我收到了EACCESS错误。


npm ERR! code EACCES
npm ERR! syscall access
npm ERR! path /usr/lib/node_modules
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, access '/usr/lib/node_modules'
npm ERR!  [Error: EACCES: permission denied, access '/usr/lib/node_modules'] {
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'access',
npm ERR!   path: '/usr/lib/node_modules'
npm ERR! }
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.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/cloudshell-user/.npm/_logs/2021-01-06T02_18_33_584Z-debug.log

What's the best way to install npm packages in AWS CloudShell?在 AWS CloudShell 中安装 npm 包的最佳方法是什么?

To get around this problem, I followed the instructions at https://docs.npmjs.com/resolving-eacces-permissions-errors-when-installing-packages-globally :为了解决这个问题,我按照https://docs.npmjs.com/resolving-eacces-permissions-errors-when-installing-packages-globally的说明进行操作:

First:第一的:

mkdir ~/.npm-global
npm config set prefix '~/.npm-global'

In your preferred text editor, open or create a ~/.profile file and add this line :在您首选的文本编辑器中,打开或创建一个 ~/.profile 文件并添加以下行

export PATH=~/.npm-global/bin:$PATH

Then:然后:

source ~/.profile

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM