Skip to content

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

@ghost

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

Metadata

Metadata

Assignees

Labels

Bugthing that needs fixingPriority 1high priority issueRelease 7.xwork is associated with a specific npm 7 release

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions