cli icon indicating copy to clipboard operation
cli copied to clipboard

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

Open ssffnet opened this issue 4 years ago • 4 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

This issue exists in the latest npm version

  • [X] 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.

ssffnet avatar Dec 09 '21 18:12 ssffnet

any updats, it's a long time bug!

liudonghua123 avatar Aug 10 '22 01:08 liudonghua123

Can you try npm 8 latest?

ljharb avatar Aug 10 '22 02:08 ljharb

Can you try npm 8 latest?

I tried the latest npm 8.16.0, the bug still exists.

liudonghua123 avatar Aug 10 '22 03:08 liudonghua123

From my invetigation (a while ago), this bug was introduced in v8.5.2. Sorry I don't recall the specifics. I've been instructing my users to roll back to [email protected] before installing my package.

EDIT: Possibly related: https://github.com/npm/cli/issues/3692

dmca-glasgow avatar Aug 10 '22 07:08 dmca-glasgow