Skip to content

Instantly share code, notes, and snippets.

@deepak-cotocus
Last active February 29, 2024 07:40
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save deepak-cotocus/0238d919153cb7dce1cd0bdda41e2973 to your computer and use it in GitHub Desktop.
Save deepak-cotocus/0238d919153cb7dce1cd0bdda41e2973 to your computer and use it in GitHub Desktop.
cross-env: Permission denied

Error:

sh: 1: cross-env: Permission denied Ubuntu

Introduction:

This is because of permission issues with global installation of packages, which npm is being denied access. I got this error in ubuntu machine while running a command npm run prod

Error:

sh: 1: cross-env: Permission denied
npm ERR! code ELIFECYCLE
npm ERR! errno 126
npm ERR! @ production: `cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --no-progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js`
npm ERR! Exit status 126
npm ERR!
npm ERR! Failed at the @ production 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!     /home/ubuntu/.npm/_logs/2020-11-05T09_35_05_202Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 126
npm ERR! @ prod: `npm run production`
npm ERR! Exit status 126
npm ERR!
npm ERR! Failed at the @ prod 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!     /home/ubuntu/.npm/_logs/2020-11-05T09_35_05_222Z-debug.log
root@ip-172-31-20-213:/opt/lampp/htdocs/mhn-admin-ms# chmod -R a+x node_modules
root@ip-172-31-20-213:/opt/lampp/htdocs/mhn-admin-ms# npm run prod

image

Solution

Worked for me

chmod -R a+x node_modules

First

sudo chown -R $USER /usr/local

And cd /path/of/project

chmod -R a+x node_modules

npm run watch

If not work

npm rebuild

npm run watch

If not work

rm -Rf node_modules

npm install

npm run watch

It worked for me....

Then run npm run prod and check evrything will work fine.

Thanks

@sztadii
Copy link

sztadii commented Feb 29, 2024

or you can just uninstall cross-env npm uninstall cross-env and install it again npm install cross-env. It worked for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment