cli icon indicating copy to clipboard operation
cli copied to clipboard

[BUG] NMP v7 error on install — 'must provide string spec'

Open davesag opened this issue 6 years ago • 28 comments

Current Behavior:

Trying to run npm install on my project api-server-boilerplate gives error

error must provide string spec

Full error log

0 verbose cli [
0 verbose cli   '/Users/davesag/.nvm/versions/node/v15.0.1/bin/node',
0 verbose cli   '/Users/davesag/.nvm/versions/node/v15.0.1/bin/npm',
0 verbose cli   'install'
0 verbose cli ]
1 info using [email protected]
2 info using [email protected]
3 timing config:load:defaults Completed in 1ms
4 timing config:load:file:/Users/davesag/.nvm/versions/node/v15.0.1/lib/node_modules/npm/npmrc Completed in 1ms
5 timing config:load:builtin Completed in 1ms
6 timing config:load:cli Completed in 1ms
7 timing config:load:env Completed in 0ms
8 timing config:load:file:/Users/davesag/src/personal/api-server-boilerplate/.npmrc Completed in 0ms
9 timing config:load:project Completed in 1ms
10 timing config:load:file:/Users/davesag/.npmrc Completed in 0ms
11 timing config:load:user Completed in 0ms
12 timing config:load:file:/Users/davesag/.nvm/versions/node/v15.0.1/etc/npmrc Completed in 0ms
13 timing config:load:global Completed in 0ms
14 timing config:load:cafile Completed in 0ms
15 timing config:load:validate Completed in 0ms
16 timing config:load:setUserAgent Completed in 1ms
17 timing config:load:setEnvs Completed in 0ms
18 timing config:load Completed in 5ms
19 verbose npm-session 6ab716390ebb1b7a
20 timing npm:load Completed in 10ms
21 timing arborist:ctor Completed in 0ms
22 timing idealTree Completed in 20ms
23 timing command:install Completed in 21ms
24 verbose stack TypeError: must provide string spec
24 verbose stack     at new Edge (/Users/davesag/.nvm/versions/node/v15.0.1/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/edge.js:32:13)
24 verbose stack     at Node.[_loadDepType] (/Users/davesag/.nvm/versions/node/v15.0.1/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/node.js:536:9)
24 verbose stack     at Node.[Arborist.Node._loadDeps] (/Users/davesag/.nvm/versions/node/v15.0.1/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/node.js:504:23)
24 verbose stack     at new Node (/Users/davesag/.nvm/versions/node/v15.0.1/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/node.js:224:20)
24 verbose stack     at Arborist.[loadVirtualNode] (/Users/davesag/.nvm/versions/node/v15.0.1/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/load-virtual.js:253:18)
24 verbose stack     at Arborist.[resolveNodes] (/Users/davesag/.nvm/versions/node/v15.0.1/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/load-virtual.js:180:43)
24 verbose stack     at Arborist.[loadFromShrinkwrap] (/Users/davesag/.nvm/versions/node/v15.0.1/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/load-virtual.js:84:46)
24 verbose stack     at Arborist.loadVirtual (/Users/davesag/.nvm/versions/node/v15.0.1/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/load-virtual.js:64:36)
24 verbose stack     at async Arborist.buildIdealTree (/Users/davesag/.nvm/versions/node/v15.0.1/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:200:7)
24 verbose stack     at async Promise.all (index 1)
25 verbose cwd /Users/davesag/src/personal/api-server-boilerplate
26 verbose Darwin 19.6.0
27 verbose argv "/Users/davesag/.nvm/versions/node/v15.0.1/bin/node" "/Users/davesag/.nvm/versions/node/v15.0.1/bin/npm" "install"
28 verbose node v15.0.1
29 verbose npm  v7.0.7
30 error must provide string spec
31 verbose exit 1

Expected Behaviour:

I expected it to install as per normal, or at least get an error that tells me what to do to fix it.

I have searched for this "must provide string spec" and can't find any results.

The only fix is to roll back npm to v6

Steps To Reproduce:

git clone [email protected]:davesag/api-server-boilerplate.git
cd api-server-boilerplate
npm install

Environment:

  • OS: macOS 10.15.7 (19H2)
  • Node: 15.0.1
  • npm: 7.0.7

davesag avatar Nov 03 '20 23:11 davesag

can you try again with npm 7.0.8? i wasn't able to reproduce this in either node 14.15.0 or 15.0.1 when using npm 7.0.8

nlf avatar Nov 04 '20 15:11 nlf

Yes 7.0.8 appears to have fixed the problem.

davesag avatar Nov 06 '20 07:11 davesag

% npm install config
npm ERR! must provide string spec

% node --version v15.2.0

% npm --version 7.0.10

sjahlstrom avatar Nov 16 '20 19:11 sjahlstrom

In my case it happened when I had a git conflict in package-lock.json and tried to run npm install.

[email protected]
[email protected]

silvenon avatar Nov 19 '20 00:11 silvenon

I can't reproduce this w/ v7.4.3 and neither could @nlf when he tried it. Without more info on how this can reliably be reproduced I'm going to close this. If this is still an issue, either reopen this with more details or create a new issue.

wraithgar avatar Jan 21 '21 21:01 wraithgar

@wraithgar unless npm has a feature of auto-resolving merge conflict in package-lock.json, no problem, otherwise I can try to come up with a repro.

silvenon avatar Jan 22 '21 08:01 silvenon

Merge conflicts can be (usually) solved by using https://github.com/npm/npm-merge-driver

wraithgar avatar Jan 22 '21 15:01 wraithgar

I'm getting this on Windows 10 (MSFT corpnet/VPN) with npm 7.0.0 after cloning:

git clone https://github.com/Azure-Samples/azure-cosmos-db-cassandra-nodejs-getting-started.git

Then running:

npm install

No lock file but the package.json file does look unusual:

{
  "name": "packages.json",
  "version": "1.0.0",
  "lockfileVersion": 1,
  "requires": true,
  "dependencies": {
    "assert": "^1.4.1",
    "async": "^2.5.0",
    "cassandra-driver": "^3.3.0",
    "dateformat": "^3.0.2",
    "long": {
      "integrity": "sha1-n6GAux2VAM3CnEFWdmoZleH0Uk8=",
      "resolved": "https://registry.npmjs.org/long/-/long-2.4.0.tgz",
      "version": "2.4.0"
    },
    "system-sleep": "^1.3.6"
  }
}

diberry avatar Feb 09 '21 23:02 diberry

@diberry can you try npm v7.5.3? v7.0.0 is missing a great many bug fixes.

ljharb avatar Feb 09 '21 23:02 ljharb

@ljharb image

diberry avatar Feb 09 '21 23:02 diberry

I'm having the same problem.

> node --version
v15.11.0
> npm --version
7.6.0
> npm install
npm ERR! must provide string spec

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/jgl/.npm/_logs/2021-03-04T10_59_06_851Z-debug.log
> cat /home/jgl/.npm/_logs/2021-03-04T10_59_06_851Z-debug.log
0 verbose cli [ '/usr/bin/node', '/usr/bin/npm', 'install' ]
1 info using [email protected]
2 info using [email protected]
3 timing config:load:defaults Completed in 0ms
4 timing config:load:file:/usr/lib/node_modules/npm/npmrc Completed in 1ms
5 timing config:load:builtin Completed in 1ms
6 timing config:load:cli Completed in 1ms
7 timing config:load:env Completed in 0ms
8 timing config:load:file:/home/jgl/dev/walcu/mapp/webclient/.npmrc Completed in 0ms
9 timing config:load:project Completed in 0ms
10 timing config:load:file:/home/jgl/.npmrc Completed in 1ms
11 timing config:load:user Completed in 1ms
12 timing config:load:file:/usr/etc/npmrc Completed in 0ms
13 timing config:load:global Completed in 0ms
14 timing config:load:cafile Completed in 0ms
15 timing config:load:validate Completed in 0ms
16 timing config:load:setUserAgent Completed in 0ms
17 timing config:load:setEnvs Completed in 1ms
18 timing config:load Completed in 4ms
19 verbose npm-session d9a89f826c253f16
20 timing npm:load Completed in 8ms
21 timing arborist:ctor Completed in 1ms
22 timing idealTree Completed in 6ms
23 timing command:install Completed in 15ms
24 verbose stack TypeError: must provide string spec
24 verbose stack     at new Edge (/usr/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/edge.js:48:13)
24 verbose stack     at Node.[_loadDepType] (/usr/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/node.js:771:9)
24 verbose stack     at Node.[Arborist.Node._loadDeps] (/usr/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/nod
e.js:758:23)
24 verbose stack     at new Node (/usr/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/node.js:231:20)
24 verbose stack     at Arborist.[rootNodeFromPackage] (/usr/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arb
orist/build-ideal-tree.js:355:18)
25 verbose cwd /home/jgl/dev/walcu/mapp/webclient
26 verbose Linux 5.11.2-arch1-1
27 verbose argv "/usr/bin/node" "/usr/bin/npm" "install"
28 verbose node v15.11.0
29 verbose npm  v7.6.0
30 error must provide string spec
31 verbose exit 1

josegl avatar Mar 04 '21 11:03 josegl

I also experienced this annoying bug after upgrading npm (on Ubuntu 18.04, installed via nodesource).

{
  npm: '7.6.1',
  node: '14.15.5',
  v8: '8.4.371.19-node.18',
  uv: '1.40.0',
  zlib: '1.2.11',
  brotli: '1.0.9',
  ares: '1.16.1',
  modules: '83',
  nghttp2: '1.41.0',
  napi: '7',
  llhttp: '2.1.3',
  openssl: '1.1.1i',
  cldr: '37.0',
  icu: '67.1',
  tz: '2020a',
  unicode: '13.0'
}

I reinstalled nodejs via apt. NPM was downgraded back to 6.x:

{
  npm: '6.14.11',
  ares: '1.16.1',
  brotli: '1.0.9',
  cldr: '37.0',
  icu: '67.1',
  llhttp: '2.1.3',
  modules: '83',
  napi: '7',
  nghttp2: '1.41.0',
  node: '14.16.0',
  openssl: '1.1.1j',
  tz: '2020a',
  unicode: '13.0',
  uv: '1.40.0',
  v8: '8.4.371.19-node.18',
  zlib: '1.2.11'
}

This fixed the issue. Is npm 7.x not compatible with node 14.x? If so, why is it upgraded by npm install -g npm ?

Feder1co5oave avatar Mar 06 '21 15:03 Feder1co5oave

npm 7.x is definitely supported on node 14

are any of you able to create a reproduction case for this? if you’re able to share your package.json and package-lock.json that would help too. we haven’t been able to reproduce this one, so any help in that would be the first step toward getting it fixed

nlf avatar Mar 06 '21 15:03 nlf

I had this problem on Ubuntu 18.04 with NPM 7.6.0 and NodeJS v15.11.0. Got the error "must provide string spec" and the debug log did not have a smoking gun in it.

I kicked my tiny package.json and created a new one, and then reinstalled all dependencies without issues. Did not need to downgrade NPM, could not reproduce the problem after that.

sprise avatar Mar 08 '21 23:03 sprise

To solve it, I had to delete package-lock.json file.

ajeetshah avatar Mar 13 '21 19:03 ajeetshah

I solve the problem by downgrade npm to 6.X.X ....

Houssk avatar Mar 16 '21 10:03 Houssk

$ npm i node-fetch
npm ERR! must provide string spec

$ npm -v
7.6.3

To solve I had to delete the package.json file.

jpall12 avatar Mar 17 '21 18:03 jpall12

I also need help with this, I'm using node v15.8.0, and I get 'must provide a string spec' when I try to npm install passport passport-discord. Are there any suggestion on which node version I should use or anything else that could fix

MrSalazer avatar Mar 24 '21 08:03 MrSalazer

Deleting package-lock.json didn't work for me. I had to downgrade to npm 6.14.11

wyatt-troia avatar Mar 27 '21 18:03 wyatt-troia

In my case I had

...
  "dependencies": {
    "//": [],
...

Since I've used it to leave comments in package.json. After removing - works fine

syabro avatar Mar 29 '21 09:03 syabro