Skip to content

[BUG] Errors when installing a GitHub repo dependency with a prepare script using a command from a dev dependency #2084

@jaydenseric

Description

@jaydenseric

Current Behavior:

npm v7 errors when installing a GitHub repo dependency that has a prepare script that uses a command from a dev dependency. The command appears to be missing when run by the prepare script.

Expected Behavior:

npm v7 should be able to install GitHub repo dependencies that have a prepare script without an error, like npm v6 could.

Steps To Reproduce:

Try npm install with this package.json:

{
  "name": "npm-prepare-script-test",
  "private": true,
  "dependencies": {
    "extract-files": "github:jaydenseric/extract-files"
  }
}

Notice the error:

npm ERR! code 1
npm ERR! git dep preparation failed
npm ERR! command /Users/jaydenseric/.asdf/installs/nodejs/14.15.0/bin/node /Users/jaydenseric/.asdf/installs/nodejs/14.15.0/.npm/lib/node_modules/npm/bin/npm-cli.js install --only=dev --prod --ignore-prepublish --no-progress --no-save --cache=/Users/jaydenseric/.npm/_cacache --prefer-offline=false --prefer-online=false --offline=false --before=
npm ERR! > [email protected] prepare
npm ERR! > npm run prepare:clean && npm run prepare:babel && npm run prepare:jsdoc && npm run prepare:prettier
npm ERR! 
npm ERR! 
npm ERR! > [email protected] prepare:clean /Users/jaydenseric/.npm/_cacache/tmp/git-clone-5acc15a1
npm ERR! > rm -rf public
npm ERR! 
npm ERR! 
npm ERR! > [email protected] prepare:babel /Users/jaydenseric/.npm/_cacache/tmp/git-clone-5acc15a1
npm ERR! > babel src -d . --keep-file-extension
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: babel: command not found
npm ERR! npm ERR! code ELIFECYCLE
npm ERR! npm ERR! syscall spawn
npm ERR! npm ERR! file sh
npm ERR! npm ERR! errno ENOENT
npm ERR! npm ERR! [email protected] prepare:babel: `babel src -d . --keep-file-extension`
npm ERR! npm ERR! spawn ENOENT
npm ERR! npm ERR! 
npm ERR! npm ERR! Failed at the [email protected] prepare:babel script.

If you use npm v6.14.8, there is no error and the package successfully installs.

Environment:

  • OS: macOS 10.15.7
  • Node.js: 14.15.0
  • npm: 7.0.3, 7.0.6

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bugthing that needs fixingNeeds Triageneeds review for next stepsRelease 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