Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] npm install script not working when I run npm install as dependency #3056

Closed
jfoclpf opened this issue Apr 9, 2021 · 2 comments
Closed
Labels
Bug thing that needs fixing Needs Triage needs review for next steps Release 7.x work is associated with a specific npm 7 release

Comments

@jfoclpf
Copy link

jfoclpf commented Apr 9, 2021

Current Behavior:

npm install script defined in package.json not running when I do npm install <packg> to install <packg> as dependency

Expected Behavior:

npm install command should run install script

Steps To Reproduce:

I created a npm package named cordova-import-npm with this script portion in package.json:

  "scripts": {
    "install": "echo \"HI THERE\""
  },

When I run npm install . inside the root of the package it works

$ npm i .

> cordova-import-npm@1.0.10 install
> echo "HI THERE"

HI THERE

up to date, audited 231 packages in 1s

48 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities

But when I install as dependency on another package, the script is not run

$ mkdir test/ && cd test/
$ npm init
$ npm install cordova-import-npm

up to date, audited 11 packages in 2s

found 0 vulnerabilities

I'm using the latest version of npm 7.9.0

Environment:

  • OS: Ubuntu 18.04
  • Node: 14.6.1
  • npm: 7.9.0
@jfoclpf jfoclpf added Bug thing that needs fixing Needs Triage needs review for next steps Release 7.x work is associated with a specific npm 7 release labels Apr 9, 2021
@wraithgar
Copy link
Member

The install scripts for a package only run when you are doing an npm install in that package's root itself, or are installing it globally.

There is no script that runs when a package is being installed, but there is an ongoing discussion about what that would look like over in the RFC repo npm/rfcs#325

@Cactusbone
Copy link

I believe install scripts are run, however console output is not displayed by default since npm 7. You need to use npm i --foreground-scripts to get console output

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug thing that needs fixing Needs Triage needs review for next steps Release 7.x work is associated with a specific npm 7 release
Projects
None yet
Development

No branches or pull requests

3 participants