【问题标题】:How to npm install in AWS CloudShell?如何在 AWS CloudShell 中安装 npm?
【发布时间】:2021-04-11 19:46:24
【问题描述】:

我正在尝试在新的 AWS CloudShell 中安装一个 npm 包(带有 pre-configured Node.js support) - 但我收到了 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

在 AWS CloudShell 中安装 npm 包的最佳方式是什么?

【问题讨论】:

    标签: node.js amazon-web-services npm aws-cloudshell


    【解决方案1】:

    为了解决这个问题,我按照https://docs.npmjs.com/resolving-eacces-permissions-errors-when-installing-packages-globally 的说明进行操作:

    第一:

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

    在您喜欢的文本编辑器中,打开或创建一个 ~/.profile 文件并添加这一行

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

    然后:

    source ~/.profile
    

    【讨论】:

      猜你喜欢
      • 2012-01-02
      • 2016-07-04
      • 2023-02-09
      • 2014-06-15
      • 2022-01-17
      • 2016-09-05
      • 2017-10-30
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多