npm / cli

the package manager for JavaScript
https://docs.npmjs.com/cli/
Other
8.49k stars 3.17k forks source link

Since v8, npm scripts fail executing #4566

Open TimDaub opened 2 years ago

TimDaub commented 2 years ago

Is there an existing issue for this?

This issue exists in the latest npm version

Current Behavior

root@strike:~/strike# npm run build:frontend

> strike@0.0.1 build:frontend
> esbuild ./client/src/VotingApp.mjs --minify --bundle --format=esm --outfile=./src/public/bundle.js

sh: 1: esbuild: Permission denied
root@strike:~/strike# npm --version
8.5.4

Expected Behavior

root@strike:~/strike# npm run build:frontend

> strike@0.0.1 build:frontend /root/strike
> esbuild ./client/src/VotingApp.mjs --minify --bundle --format=esm --outfile=./src/public/bundle.js

  src/public/bundle.js  73.4kb

⚡ Done in 57ms
root@strike:~/strike# npm -v
6.14.16

Steps To Reproduce

No response

Environment

; node bin location = /usr/bin/node ; cwd = /root/strike ; HOME = /root ; "npm config ls -l" to show all defaults.



## workaround

downgrading npm@6 fixes the problem
wraithgar commented 2 years ago

We will need more info to replicate this. Is esbuild a dependency of your package? What does your package.json look like? Have you installed the dependencies? With what command?

TimDaub commented 2 years ago

esbuild is locally installed and accessible via npm scripts. which esbuild yields nothing as it wasn't installed globally. I did the two commands one after each other after downgrading npm to v6.

wraithgar commented 2 years ago

We need a way to replicate this locally. If I install esbuild into a package w/ npm@6 and then use npm@8 to run it it works fine.

~/D/n/s/esb $ npx npm@6 install esbuild
~/D/n/s/esb $ npm pkg get scripts.foo
"esbuild"
~/D/n/s/esb $ npm run foo

> esb@1.0.0 foo
> esbuild

Usage:
  esbuild [options] [entry points]
nlf commented 2 years ago

the permission denied portion of the error makes it look like the esbuild bin script isn't executable. you can try removing your node_modules and re-running npm i to see if npm will fix it for you, or chmod +x node_modules/.bin/esbuild to manually fix it yourself

TimDaub commented 2 years ago
[ -x ./node_modules/.bin/esbuild ] && echo "File is executable" || echo "File isn't"
File is executable

according to this SE post