npm / npm/cli

[BUG] Prepare script not running on global install from repo

Open
#4,148 4 comments 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Bug Needs Triage Release 8.x
Dominant language
JavaScript
Stars
10.1k
Forks
4.7k
Avg merge
2d 2h
Merged PRs (30d)
19

Description

Is there an existing issue for this?
  • I have searched the existing issues
This issue exists in the latest npm version
  • I am using the latest npm
Current Behavior

Installing globally -g from repo results in link to deleted temp folder and no installation files.

npm install -g github:ssffnet/npm-global-install-bug.git

# check for install files but find link instead
ls -la ~/.nvm/versions/node/v16.13.1/lib/node_modules
lrwxrwxrwx 1 ......51 Dec 9 18:20 global-prepare-bug -> ../../../../../../.npm/_cacache/tmp/git-clonepo3KRt

# check for this temp folder - nothing
ls ~/.npm/_cacache/tmp
<nothing>

Really simple package.json that only creates a text file when prepare runs - no dependencies

{
  "name": "global-prepare-bug",
  "version": "1.0.0",
  "description": "Global npm install from repo fails to run prepare script.",
  "main": "hello.js",
  "scripts": {
    "prepare": "echo prepare > prepare.executed.txt"
  },
  "license": "ISC"
}
Expected Behavior

prepare script to run as with npm 6.x:

After install:

ls ~/.nvm/versions/node/v14.18.2/lib/node_modules/global-prepare-bug
hello.js  package.json  prepare.executed.txt
Steps To Reproduce

on node 16.13.1, npm 8.2.0, Ubuntu 18.04 LTS

  1. install simple package globally from repo
npm install -g github:ssffnet/npm-global-install-bug.git
  1. check install folder
ls -la ~/.nvm/versions/node/v16.13.1/lib/node_modules
  1. expect to see
hello.js  package.json  prepare.executed.txt
  1. instead see broken link and no files
global-prepare-bug -> ../../../../../../.npm/_cacache/tmp/git-clonepo3KRt
Environment
  • npm: 8.2.0
  • Node: 16.13.1
  • OS: Ubuntu 18
  • platform: Linux 5.4.0-1064-azure 67~18.04.1-Ubuntu SMP x86_64 x86_64 x86_64 GNU/Linux
  • npm config:
; node bin location = /home/foo/.nvm/versions/node/v16.13.1/bin/node
; cwd = /home/foo/.nvm/versions/node/v16.13.1/lib/node_modules
; HOME = /home/foo
; Run `npm config ls -l` to show all defaults.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the minimal package.json and reproduce the global GitHub install using npm 8.2.0 on Node 16.13.1. Trace the global-install and prepare-script behavior responsible for the broken link, then verify that the installed package contains hello.js, package.json, and prepare.executed.txt rather than linking to the deleted cache directory.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, nodejs
Domain
cli
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.