3

Can anyone help me to get rid out of the following error -

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.

I have tried following solutions - 1. created a file under .elasticbeanstalk dir with following codes -

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. Upgraded instance type to t2.medium to avoid memory related exception

    Following is my config.yaml file

    enter image description here

and package.json file has following contents -

{
  "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"
  ]
}

Thanks much!!

Sachin Vairagi
  • 4,894
  • 4
  • 35
  • 61

2 Answers2

10

After trying everything, finally following solution worked for me :)

The solution is to add the file .npmrc to the application root directory with the content:

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

Reference -

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

Sachin Vairagi
  • 4,894
  • 4
  • 35
  • 61
  • 1
    this was the best thing I found, I spent like 3 hours trying to solve this, thanks !! – Jimmar Jun 08 '22 at 19:57
  • I'm still getting an issue with the playwright library because it is trying to install some cache files at `/root/.cache/ms-playwright` Any clue how to fix it here? – Y M Dec 23 '22 at 07:12
  • @Y M Can you please share complete logs? – Sachin Vairagi Dec 24 '22 at 05:39
  • On Mac: Use sudo command. You must be an administrator or root user, also called superuser, to execute many of the commands used to manage a server. https://support.apple.com/en-in/guide/terminal/apd5b0b6259-a7d4-4435-947d-0dff528912ba/mac#:~:text=To%20run%20commands%20with%20superuser,sudo%20stands%20for%20superuser%20do.&text=You're%20asked%20for%20the%20password%20of%20the%20current%20user.&text=You're%20asked%20to%20enter,is%20opened%20for%20that%20user. – himanshupareek66 Feb 19 '23 at 13:07
0

I had a troublesome library that was causing this issue. Using the "unsafe-perm=true" did not resolve the problem.

Instead I changed the cache folder location per How can I change the cache path for npm (or completely disable the cache) on Windows? to npm_config_cache=/tmp using the eb setenv command. Libraries are installed properly now when doing a eb deploy.

There may be some performance implications to doing this, but I've not noticed anything thus far.

Vik
  • 1,301
  • 4
  • 16
  • 29