Skip to content

devDependencies of git dependency are missing during prepare when installing with --prod in main package #2920

Closed

Description

Current Behavior:

Dev dependencies of git dependency are missing during prepare in npm v7 (npm v6 works fine) when the main package dependencies are installed using the --prod flag.

Expected Behavior:

If the package being installed contains a prepare script, its dependencies and devDependencies will be installed, and the prepare script will be run, before the package is packaged and installed.

Steps To Reproduce:

Package 1 (main):

{
  "name": "main-package",
  "version": "0.0.0",
  "scripts": {},
  "dependencies": {
    "git-dep": "git+ssh://[email protected]:<user>/<repo>.git"
  },
  "devDependencies": {
    "typescript": "^4.2.3"
  }
}

Package 2 (git dependency):

{
  "name": "git-dep",
  "version": "0.0.0",
  "scripts": {
    "prepare": "npm run build",
    "build": "tsc -b --verbose tsconfig.build.json"
  },
  "dependencies": {},
  "devDependencies": {
    "typescript": "^4.2.3"
  }
}

Run npm ci or npm i in main package with prod flag, npm ci --prod:

npm ERR! > [email protected] prepare
npm ERR! > npm run build
npm ERR! 
npm ERR! 
npm ERR! > [email protected] build
npm ERR! > tsc -b --verbose tsconfig.build.json
npm ERR! npm WARN using --force Recommended protections disabled.
npm ERR! npm WARN using --force Recommended protections disabled.
npm ERR! sh: 1: tsc: not found
npm ERR! npm ERR! code 127
npm ERR! npm ERR! path /home/XXXX/.npm/_cacache/tmp/git-clone-XXXXXXX
npm ERR! npm ERR! command failed
npm ERR! npm ERR! command sh -c tsc -b --verbose tsconfig.build.json
npm ERR! 
npm ERR! npm ERR! A complete log of this run can be found in:
npm ERR! npm ERR!     /home/XXXX/.npm/_logs/XXXXXXXXXXXXXXXX-debug.log
npm ERR! npm ERR! code 127
npm ERR! npm ERR! path /home/XXXX/.npm/_cacache/tmp/git-clone-XXXXX
npm ERR! npm ERR! command failed
npm ERR! npm ERR! command sh -c npm run build

npm ERR! sh: 1: tsc: not found ==> tsc should not be missing, as it should come with the typescript devDependency of the git-dep

Seems to be similar to #1865

Environment:

  • OS: Ubuntu 18.04
  • Node: 15.8.0
  • npm: 7.6.3

Activity

  1. ghost added
    Bug
    on Mar 23, 2021
  2. ghost added
    Needs Triage
    on Mar 23, 2021
  3. ghost added
    Release 7.x
    on Mar 23, 2021
  4. removed
    Needs Triage
    on May 14, 2021
  5. added
    Priority 1
    on May 14, 2021
  6. isaacs commented on Jun 18, 2021

    @isaacs
    Contributor

    Will be closed when npm/pacote#81 lands.

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

Metadata

Metadata

Assignees

Labels

BugPriority 1Release 7.x

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions