Current Behavior:
In a workspace, npm install fails for a package with a "bin" script defined in package.json that doesn't exist. NPM tries to chmod the non-existent "bin" script, resulting in ENOENT error.
npm ERR! code ENOENT
npm ERR! syscall chmod
npm ERR! path /home/timothy/dev/npm7-bin-link-issue/node_modules/cli/lib/index.js
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, chmod '/home/timothy/dev/npm7-bin-link-issue/node_modules/cli/lib/index.js'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
Expected Behavior:
npm install should succeed and NPM should not attempt to chmod "bin" scripts if they don't exist.
Steps To Reproduce:
The scenario of a non-existent "bin" script is easy to encounter in a TypeScript monorepo using NPM workspaces, where a "bin" script may point to a .js file that doesn't exist until the TS is transpiled to JS.
To reproduce the error, clone this minimal sample repo and run npm install. Or follow the steps below:
- Create an NPM project:
npm init -y
- Define the
workspaces property in top-level package.json:
"workspaces": [ "./packages/*" ]
- Create the directory structure "packages/cli" and generate a package.json there:
cd packages/cli && npm init -y
- Define
bin property in "packages/cli/package.json" and point to a non-existent script:
"bin": { "test-cli": "./nonexistent.js" }
- Run
npm install at top level of project and see ENOENT
Environment:
- OS: Ubuntu 18.04
- Node: 15.8.0
- npm: 7.5.1
Current Behavior:
In a workspace,
npm installfails for a package with a "bin" script defined in package.json that doesn't exist. NPM tries to chmod the non-existent "bin" script, resulting in ENOENT error.Expected Behavior:
npm installshould succeed and NPM should not attempt to chmod "bin" scripts if they don't exist.Steps To Reproduce:
The scenario of a non-existent "bin" script is easy to encounter in a TypeScript monorepo using NPM workspaces, where a "bin" script may point to a
.jsfile that doesn't exist until the TS is transpiled to JS.To reproduce the error, clone this minimal sample repo and run
npm install. Or follow the steps below:npm init -yworkspacesproperty in top-level package.json:"workspaces": [ "./packages/*" ]cd packages/cli && npm init -ybinproperty in "packages/cli/package.json" and point to a non-existent script:"bin": { "test-cli": "./nonexistent.js" }npm installat top level of project and see ENOENTEnvironment: