Nexmo / nexmo-cli

Nexmo CLI (Command Line Interface)
https://nexmo.com
MIT License
78 stars 52 forks source link

`npm install -g nexmo-cli` fails on `prepublish` #95

Closed leggetter closed 7 years ago

leggetter commented 7 years ago

Steps to reproduce

Debug:

0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/Cellar/node/6.7.0/bin/node',
1 verbose cli   '/usr/local/bin/npm',
1 verbose cli   'install',
1 verbose cli   'nexmo-cli',
1 verbose cli   '-g' ]
2 info using npm@3.10.7
3 info using node@v6.7.0
4 silly loadCurrentTree Starting
5 silly install loadCurrentTree
6 silly install readGlobalPackageData
7 silly fetchPackageMetaData nexmo-cli
8 silly fetchDirectoryPackageData nexmo-cli
9 silly install normalizeTree
10 silly loadCurrentTree Finishing
11 silly loadIdealTree Starting
12 silly install loadIdealTree
13 silly cloneCurrentTree Starting
14 silly install cloneCurrentTreeToIdealTree
15 silly cloneCurrentTree Finishing
16 silly loadShrinkwrap Starting
17 silly install loadShrinkwrap
18 silly loadShrinkwrap Finishing
19 silly loadAllDepsIntoIdealTree Starting
20 silly install loadAllDepsIntoIdealTree
21 silly resolveWithNewModule nexmo-cli@0.2.0 checking installable status
22 silly cache add args [ 'nexmo-cli', null ]
23 verbose cache add spec nexmo-cli
24 silly cache add parsed spec Result {
24 silly cache add   raw: 'nexmo-cli',
24 silly cache add   scope: null,
24 silly cache add   escapedName: 'nexmo-cli',
24 silly cache add   name: null,
24 silly cache add   rawSpec: 'nexmo-cli',
24 silly cache add   spec: '/Users/user_name/nexmo-cli',
24 silly cache add   type: 'directory' }
25 verbose addLocalDirectory /Users/user_name/.npm/nexmo-cli/0.2.0/package.tgz not in flight; packing
26 verbose correctMkdir /Users/user_name/.npm correctMkdir not in flight; initializing
27 verbose makeDirectory /Users/user_name/.npm creation not in flight; initializing
28 silly makeDirectory /Users/user_name/.npm uid: 860087178 gid: 20
29 info lifecycle nexmo-cli@0.2.0~prepublish: nexmo-cli@0.2.0
30 verbose lifecycle nexmo-cli@0.2.0~prepublish: unsafe-perm in lifecycle true
31 verbose lifecycle nexmo-cli@0.2.0~prepublish: PATH: /usr/local/lib/node_modules/npm/bin/node-gyp-bin:/Users/user_name/nexmo-cli/node_modules/.bin:/usr/local/Cellar/node/6.7.0/bin:/Users/user_name/DevApps/activator-dist-1.3.10/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin
32 verbose lifecycle nexmo-cli@0.2.0~prepublish: CWD: /Users/user_name/nexmo-cli
33 silly lifecycle nexmo-cli@0.2.0~prepublish: Args: [ '-c', 'npm run build' ]
34 silly lifecycle nexmo-cli@0.2.0~prepublish: Returned: code: 1  signal: null
35 info lifecycle nexmo-cli@0.2.0~prepublish: Failed to exec prepublish script
36 error addLocal Could not install /Users/user_name/nexmo-cli
37 silly rollbackFailedOptional Starting
38 silly rollbackFailedOptional Finishing
39 silly runTopLevelLifecycles Finishing
40 silly install printInstalled
41 verbose stack Error: nexmo-cli@0.2.0 prepublish: `npm run build`
41 verbose stack Exit status 1
41 verbose stack     at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/lifecycle.js:255:16)
41 verbose stack     at emitTwo (events.js:106:13)
41 verbose stack     at EventEmitter.emit (events.js:191:7)
41 verbose stack     at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/spawn.js:40:14)
41 verbose stack     at emitTwo (events.js:106:13)
41 verbose stack     at ChildProcess.emit (events.js:191:7)
41 verbose stack     at maybeClose (internal/child_process.js:877:16)
41 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
42 verbose pkgid nexmo-cli@0.2.0
43 verbose cwd /Users/user_name
44 error Darwin 15.6.0
45 error argv "/usr/local/Cellar/node/6.7.0/bin/node" "/usr/local/bin/npm" "install" "nexmo-cli" "-g"
46 error node v6.7.0
47 error npm  v3.10.7
48 error code ELIFECYCLE
49 error nexmo-cli@0.2.0 prepublish: `npm run build`
49 error Exit status 1
50 error Failed at the nexmo-cli@0.2.0 prepublish script 'npm run build'.
50 error Make sure you have the latest version of node.js and npm installed.
50 error If you do, this is most likely a problem with the nexmo-cli package,
50 error not with npm itself.
50 error Tell the author that this fails on your system:
50 error     npm run build
50 error You can get information on how to open an issue for this project with:
50 error     npm bugs nexmo-cli
50 error Or if that isn't available, you can get their info via:
50 error     npm owner ls nexmo-cli
50 error There is likely additional logging output above.
51 verbose exit [ 1, true ]

Expected behavior

Should install without error

Actual behavior

Errors as shown in log

See: https://github.com/npm/npm/issues/3059

System configuration

Node version: v6.7.0

NPM version: 3.10.7

Operating system: Darwin 15.6.0

leggetter commented 7 years ago

I've tried to reproduce this with Node v6.7.0 and npm v3.10.8 and the install succeeds. I don't have any modules installed as global and no local modules installed.

Anybody else?

cbetta commented 7 years ago

I tried in Node 6.7.0 and NPM 3.10.3 and it worked fine.

Also prepublish should not be called on install should it?

cbetta commented 7 years ago

Even tried this on 6.7.0/3.10.7 and still works.

leggetter commented 7 years ago

You wouldn't expect prepublish to run upon install. But apparently it's does "by design" https://github.com/npm/npm/issues/3059

cbetta commented 7 years ago

@leggetter we're not running NPM 1.2.0 though, and that issue is quite old.

Regardless: unless we can replicate this issue across multiple machines it's going to be hard to pinpoint the issue. I guess guidance for now for anyone having an issue is to look at their NPM version and upgrade?

leggetter commented 7 years ago

The debug log of failure shows that the version of NPM isn't an old version:

2 info using npm@3.10.7
3 info using node@v6.7.0

I wonder if the install was performed locally?! https://docs.npmjs.com/misc/scripts (see prepublish)

In the log I can see:

silly cache add   spec: '/Users/user_name/nexmo-cli'
cbetta commented 7 years ago

@leggetter sure but the bug report is from an old version.

Can you try:

npm uninstall nexmo-cli
npm uninstall nexmo-cli -g

and then try reinstall again?

leggetter commented 7 years ago

AFAICT this problem resulted from installing nexmo-cli from a local version pulled from GitHub. That results in the prepublish script being run which then introduces local dependencies that the person had to install. Running npm install within the nexmo-cli directory would have done that.

So I don't see this as a problem.

cbetta commented 7 years ago

@leggetter yeah that makes sense. I wonder if we can detect this kind of install and do something about it to prevent it.