cli icon indicating copy to clipboard operation
cli copied to clipboard

[BUG] scripts-prepend-node-path not respected in npm v8.1.2

Open sajal50 opened this issue 5 years ago • 1 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

This issue exists in the latest npm version

  • [X] I am using the latest npm

Current Behavior

I have a postinstall script in my package.json which does which node.

{
  "name": "test",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "postinstall": "which node"
  },
  "keywords": [],
  "author": "",
  "license": "ISC"
}

With node v16.13.1 and npm v8.1.2, I get the following result -

sajal@C02WM2ARHTDD test % ../node-v16.13.1-darwin-x64/bin/node ../node-v16.13.1-darwin-x64/bin/npm install --scripts-prepend-node-path=true

> [email protected] postinstall
> which node

/usr/local/bin/node

up to date, audited 1 package in 554ms

found 0 vulnerabilities
sajal@C02WM2ARHTDD test % 

node is resolving to my global installation.

Expected Behavior

However, with node v14.8.2 and npm v6.14.15, node resolves to my local installation -

sajal@C02WM2ARHTDD test % ../node-v14.18.2-darwin-x64/bin/node ../node-v14.18.2-darwin-x64/bin/npm install --scripts-prepend-node-path=true

> [email protected] postinstall /Users/sajal/Desktop/sajal_ws/test
> which node

/Users/sajal/Desktop/sajal_ws/node-v14.18.2-darwin-x64/bin/node
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN [email protected] No description
npm WARN [email protected] No repository field.

up to date in 0.376s
found 0 vulnerabilities

sajal@C02WM2ARHTDD test

IIUC, with scripts-prepend-node-path=true, should continue to resolve to my local installation even with node v16.13.1 and npm v8.1.2. If this has been deprecated, please let me know.

Steps To Reproduce

As explained in Current Behavior section.

Environment

  • OS: macOS 10.15.7
  • platform: Macbook Pro

sajal50 avatar Dec 06 '21 14:12 sajal50

https://github.com/npm/cli/issues/2808

wraithgar avatar Dec 13 '21 19:12 wraithgar