Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
davesag opened this issue Nov 3, 2020 · 28 comments
Closed

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

davesag opened this issue Nov 3, 2020 · 28 comments
Labels
Bug thing that needs fixing Release 7.x work is associated with a specific npm 7 release

Comments

@davesag
Copy link

davesag commented Nov 3, 2020

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 davesag added Bug thing that needs fixing Needs Triage needs review for next steps Release 7.x work is associated with a specific npm 7 release labels Nov 3, 2020
@nlf
Copy link
Contributor

nlf commented Nov 4, 2020

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

@davesag
Copy link
Author

davesag commented Nov 6, 2020

Yes 7.0.8 appears to have fixed the problem.

@davesag davesag closed this as completed Nov 6, 2020
@darcyclarke darcyclarke added this to the OSS - Sprint 19 milestone Nov 16, 2020
@sjahlstrom
Copy link

sjahlstrom commented Nov 16, 2020

% npm install config
npm ERR! must provide string spec

% node --version
v15.2.0

% npm --version
7.0.10

@davesag davesag reopened this Nov 16, 2020
@silvenon
Copy link

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

@wraithgar
Copy link
Member

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 wraithgar removed the Needs Triage needs review for next steps label Jan 21, 2021
@silvenon
Copy link

@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.

@wraithgar
Copy link
Member

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

@diberry
Copy link

diberry commented Feb 9, 2021

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"
  }
}

@ljharb
Copy link
Contributor

ljharb commented Feb 9, 2021

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

@diberry
Copy link

diberry commented Feb 9, 2021

@ljharb
image

@josegl
Copy link

josegl commented Mar 4, 2021

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

@Feder1co5oave
Copy link

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 ?

@nlf
Copy link
Contributor

nlf commented Mar 6, 2021

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

@sprise
Copy link

sprise commented Mar 8, 2021

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.

@ajeetshah
Copy link

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

@Houssk
Copy link

Houssk commented Mar 16, 2021

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

@jpall12
Copy link

jpall12 commented Mar 17, 2021

$ 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.

@MrSalazer
Copy link

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

@wyatt-troia
Copy link

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

@syabro
Copy link

syabro commented Mar 29, 2021

In my case I had

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

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

@ronilaukkarinen
Copy link

Strangely enough, on my machine this happens only on Windows 10 / WSL with nodejs 7.x.x installed.

Logfile 2021-06-21T18_29_07_396Z-debug.log:

0 verbose cli [
0 verbose cli   'C:\\Program Files\\nodejs\\node.exe',
0 verbose cli   'C:\\Users\\Rolle\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js',
0 verbose cli   'i',
0 verbose cli   'node-fetch'
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:C:\Users\Rolle\AppData\Roaming\npm\node_modules\npm\npmrc Completed in 0ms
5 timing config:load:builtin Completed in 0ms
6 timing config:load:cli Completed in 1ms
7 timing config:load:env Completed in 0ms
8 timing config:load:file:C:\Users\Rolle\Projects\rollemaa\.npmrc Completed in 0ms
9 timing config:load:project Completed in 1ms
10 timing config:load:file:C:\Users\Rolle\.npmrc Completed in 0ms
11 timing config:load:user Completed in 0ms
12 timing config:load:file:C:\Users\Rolle\AppData\Roaming\npm\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 4ms
19 verbose npm-session 73e796bf8774024c
20 timing npm:load Completed in 10ms
21 timing arborist:ctor Completed in 0ms
22 timing idealTree Completed in 5ms
23 timing command:install Completed in 7ms
24 verbose stack TypeError: must provide string spec
24 verbose stack     at new Edge (C:\Users\Rolle\AppData\Roaming\npm\node_modules\npm\node_modules\@npmcli\arborist\lib\edge.js:32:13)
24 verbose stack     at Node.[_loadDepType] (C:\Users\Rolle\AppData\Roaming\npm\node_modules\npm\node_modules\@npmcli\arborist\lib\node.js:530:9)
24 verbose stack     at Node.[Arborist.Node._loadDeps] (C:\Users\Rolle\AppData\Roaming\npm\node_modules\npm\node_modules\@npmcli\arborist\lib\node.js:519:25)
24 verbose stack     at new Node (C:\Users\Rolle\AppData\Roaming\npm\node_modules\npm\node_modules\@npmcli\arborist\lib\node.js:226:20)
24 verbose stack     at Arborist.[rootNodeFromPackage] (C:\Users\Rolle\AppData\Roaming\npm\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\build-ideal-tree.js:335:12)
24 verbose stack     at C:\Users\Rolle\AppData\Roaming\npm\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\build-ideal-tree.js:283:42
24 verbose stack     at async Arborist.buildIdealTree (C:\Users\Rolle\AppData\Roaming\npm\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\build-ideal-tree.js:199:7)
24 verbose stack     at async Promise.all (index 1)
24 verbose stack     at async Arborist.reify (C:\Users\Rolle\AppData\Roaming\npm\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\reify.js:121:5)
24 verbose stack     at async install (C:\Users\Rolle\AppData\Roaming\npm\node_modules\npm\lib\install.js:40:5)
25 verbose cwd C:\Users\Rolle\Projects\rollemaa
26 verbose Windows_NT 10.0.19042
27 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\Rolle\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "i" "node-fetch"
28 verbose node v14.0.0
29 verbose npm  v7.0.0
30 error must provide string spec
31 verbose exit 1

Solution: Downgrade npm to 6.14.11 with npm install -g [email protected].

@afalahi
Copy link

afalahi commented Aug 25, 2021

I'm having the same issue with npm v7.20 and NodeJS v16. I using create-react-app when running into this error. I had to downgrade to NPM v6.14 since that's the only solution that seemed to work. What's going on?

@rmacrino
Copy link

rmacrino commented Sep 1, 2021

I'm having the same issue with npm 7.21.1
I had to download version 6.14 and it worked fine

@josegl
Copy link

josegl commented Sep 2, 2021

In my case I had

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

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

That was the actual problem, in npm versions > 6.14 the package.json comments are not supported anymore as @syabro commented last March. I faced this issue last spring as well, so I inspected the run of npm install with the --inspect-brk flag in order to locate the problem, and voilà, I had a comment in my package.json, so deleting it fixed the problem.

@JattCoder
Copy link

Try deleting package-lock.json file and try again -> npm i

@ronilaukkarinen
Copy link

For me it was the old browserslist syntax in package.json:

    "browserslist": [
      "last 2 version",
      "> 1%"
    ],

After removing this verything works with npm 7-8.

@IPI-Paul
Copy link

IPI-Paul commented Nov 8, 2021

I just had the must provide string spec error when trying to run nmp install puppeteer

Everything was okay until I ran npm install npm -g, before running npm install -g typescript

So I tried npm install -g puppeteer and it worked without error

@snpiyasooriya
Copy link

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

this worked for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug thing that needs fixing Release 7.x work is associated with a specific npm 7 release
Projects
None yet
Development

No branches or pull requests