【问题标题】:AWS elastic beanstalk - WARN install EACCES: permission denied, access '/tmp/.npm'AWS弹性beantalk - 警告安装EACCES:权限被拒绝,访问'/tmp/.npm'
【发布时间】:2019-11-12 17:48:45
【问题描述】:

谁能帮我摆脱以下错误 -

WARN install EACCES: permission denied, access '/tmp/.npm'
  gyp ERR! clean error 
  gyp ERR! stack Error: EACCES: permission denied, rmdir 'build/bindings'
  gyp ERR! System Linux 4.14.123-86.109.amzn1.x86_64
  gyp ERR! command "/opt/elasticbeanstalk/node-install/node-v10.16.0-linux-x64/bin/node" "/opt/elasticbeanstalk/node-install/node-v10.16.0-linux-x64/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
  gyp ERR! cwd /tmp/deployment/application/node_modules/iltorb
  gyp ERR! node -v v10.16.0
  gyp ERR! node-gyp -v v3.8.0
  gyp ERR! not ok 
  npm ERR! code ELIFECYCLE
  npm ERR! errno 1
  npm ERR! iltorb@2.4.3 install: `node ./scripts/install.js || node-gyp rebuild`
  npm ERR! Exit status 1
  npm ERR! 
  npm ERR! Failed at the iltorb@2.4.3 install script.
  npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

我尝试了以下解决方案 - 1. 在 .elasticbeanstalk 目录下创建一个文件,代码如下 -

files:
  "/opt/elasticbeanstalk/hooks/appdeploy/post/99_fix_node_permissions.sh":
    mode: "000755"
    owner: root
    group: root
    content: |
      #!/usr/bin/env bash
      chown -R nodejs:nodejs /tmp/.npm/
  1. 将实例类型升级为 t2.medium 以避免内存相关异常

    以下是我的 config.yaml 文件

package.json 文件有以下内容 -

{
  "name": "shards-dashboard-lite-react",
  "version": "1.0.0",
  "private": true,
  "homepage": "./",
  "dependencies": {
    "camelize": "^1.0.0",
    "chart.js": "^2.7.3",
    "classnames": "^2.2.6",
    "cross-env": "^5.2.0",
    "dateformat": "^3.0.3",
    "flux": "^3.1.3",
    "lodash.find": "^4.6.0",
    "react": "^16.6.3",
    "react-dom": "^16.6.3",
    "react-ga": "^2.5.6",
    "react-quill": "^1.3.3",
    "react-router-dom": "^4.3.1",
    "react-scripts": "2.1.1",
    "shards-react": "^1.0.0",
    "shortid": "^2.2.14"
  },
  "scripts": {
    "start": "set PORT=8081 && react-scripts start",
    "build:prod": "npm run build",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": "react-app"
  },
  "browserslist": [
    ">0.2%",
    "not dead",
    "not ie <= 11",
    "not op_mini all"
  ]
}

非常感谢!!

【问题讨论】:

    标签: reactjs amazon-web-services amazon-elastic-beanstalk


    【解决方案1】:

    在尝试了一切之后,最终以下解决方案对我有用:)

    解决方法是将.npmrc文件添加到应用程序根目录,内容如下:

    # Force npm to run node-gyp also as root, preventing permission denied errors in AWS with npm@5
    unsafe-perm=true
    

    参考 -

    Beanstalk: Node.js deployment - node-gyp fails due to permission denied

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-08-05
      • 1970-01-01
      • 2020-03-06
      • 1970-01-01
      • 1970-01-01
      • 2020-12-07
      • 2019-10-28
      • 2018-04-04
      相关资源
      最近更新 更多