Skip to content

[BUG] prepare and prepack scripts are not handled as documented when installing a git dependency #1865

Closed
@kimamula

Description

@kimamula

Current Behavior:

I tested installing a git dependency which has either prepare or prepack script with npm CLI v7.0.0-beta.12 and confirmed the following behaviors.

  • a package with a prepare script: devDependencies are NOT installed but the prepare script is executed
  • a package with a prepack script: devDependencies are NOT installed and the prepack script is NOT executed

Expected Behavior:

  • a package with a prepare script: devDependencies are installed and the prepare script is executed
  • a package with a prepack script: devDependencies are installed and the prepack script is executed
    • Though I've not found any document saying that devDependencies are installed when installing a git dependency with a prepack script and actually they are not installed even when npm CLI v6 is used, I believe npm should install them since running a prepack script without installing devDependencies does not make sense.

Steps To Reproduce:

prepare:

// https://github.com/kimamula/prepare-test/blob/master/package.json
{
  "name": "prepare-test",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "prepare": "tsc"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "typescript": "^4.0.3"
  }
}
$ npm install github:kimamula/prepare-test
npm ERR! code 127
npm ERR! git dep preparation failed
npm ERR! command /Users/kenji/.nodenv/versions/12.18.3/bin/node /Users/kenji/.nodenv/versions/12.18.3/lib/node_modules/npm/bin/npm-cli.js install --only=dev --prod --ignore-prepublish --no-progress --no-save --cache=/Users/kenji/.npm/_cacache --prefer-offline=false --prefer-online=false --offline=false --before=
npm ERR! > prepare-test@1.0.0 prepare
npm ERR! > tsc
npm ERR! npm WARN invalid config before="" set in command line options
npm ERR! npm WARN invalid config Must be one of: null, valid Date string
npm ERR! sh: tsc: command not found
npm ERR! npm ERR! code 127
npm ERR! npm ERR! path /Users/kenji/.npm/_cacache/tmp/git-clone-a73f300b
npm ERR! npm ERR! command failed
npm ERR! npm ERR! command sh -c tsc
npm ERR! 
npm ERR! npm ERR! A complete log of this run can be found in:
npm ERR! npm ERR!     /Users/kenji/.npm/_cacache/_logs/2020-09-27T06_13_19_941Z-debug.log

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/kenji/.npm/_logs/2020-09-27T06_13_19_972Z-debug.log

prepack:

// https://github.com/kimamula/prepack-test/blob/master/package.json
{
  "name": "prepack-test",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "prepack": "tsc"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "typescript": "^4.0.3"
  }
}
$ npm install github:kimamula/prepack-test

changed 1 package, and audited 1 package in 6s

found 0 vulnerabilities

-> tsc should generate index.js file, but it's not generated.

Environment:

  • OS: macOS 10.15.6
  • Node: 12.18.3
  • npm: 7.0.0-beta.12

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bugthing that needs fixingRelease 7.xwork is associated with a specific npm 7 release

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions