Getting "npm ERR! code ELIFECYCLE npm ERR! errno 126" while running npm install

writeToBhuwan picture writeToBhuwan · Mar 6, 2019 · Viewed 9.2k times · Source

I am trying to run npm install on my server and getting this error.

> [email protected] postinstall /home/workspace/AgreementCancellationProd/retrymechanism/node_modules/node-cron
> opencollective-postinstall

/usr/bin/env: node: Permission denied
npm WARN [email protected] No description
npm WARN [email protected] No repository field.

npm ERR! code ELIFECYCLE
npm ERR! errno 126
npm ERR! [email protected] postinstall: `opencollective-postinstall`
npm ERR! Exit status 126
npm ERR!
npm ERR! Failed at the [email protected] postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2019-03-06T11_22_15_832Z-debug.log

NPM install is running fine on my local system but fails on server.

Also, when I try to install [email protected] using npm install [email protected], it throws the same error.

I am using Amazon Linux on EC2.

I've tried cleaning cache, deleting node_modules & package-lock.json and installing again. Nothing worked.

This is my package.json :

{
  "name": "retrymechanism",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "express": "^4.16.4",
    "fs": "0.0.1-security",
    "mysql2": "^1.6.5",
    "node-cron": "^2.0.3",
    "request": "^2.88.0",
    "sequelize": "^4.42.0"
  }
}

What could be the problem? Please help!

Answer

I ran into the same problem I used yarn to solve the issue I think it's related to the npm version :

yarn add [email protected]