npm audit EINVALIDTAGNAME

Viewed 2783

When I execute npm audit in a folder with the project's package.json and package-lock.json I get the following error:

0 info it worked if it ends with ok
1 verbose cli [ '/home/user/Downloads/node-v10.14.0-linux-x64/bin/node',
1 verbose cli   '/home/user/Downloads/node-v10.14.0-linux-x64/bin/npm',
1 verbose cli   'audit' ]
2 info using npm@6.5.0
3 info using node@v10.14.0
4 verbose npm-session d5b5c65bd8e7ae03
5 verbose stack Error: Invalid tag name "[object Object]": Tags may not have any characters that encodeURIComponent encodes.
5 verbose stack     at invalidTagName (/home/user/Downloads/node-v10.14.0-linux-x64/lib/node_modules/npm/node_modules/npm-package-arg/npa.js:87:15)
5 verbose stack     at fromRegistry (/home/user/Downloads/node-v10.14.0-linux-x64/lib/node_modules/npm/node_modules/npm-package-arg/npa.js:290:13)
5 verbose stack     at Function.resolve (/home/user/Downloads/node-v10.14.0-linux-x64/lib/node_modules/npm/node_modules/npm-package-arg/npa.js:77:12)
5 verbose stack     at Object.keys.forEach.name (/home/user/Downloads/node-v10.14.0-linux-x64/lib/node_modules/npm/node_modules/lock-verify/index.js:26:26)
5 verbose stack     at Array.forEach (<anonymous>)
5 verbose stack     at Promise.all.then.result (/home/user/Downloads/node-v10.14.0-linux-x64/lib/node_modules/npm/node_modules/lock-verify/index.js:25:25)
6 verbose cwd /home/user/projects/test-npm/CRYPTOSTORAGE/repos/crypto-storage/etc/approvalClient
7 verbose Linux 3.10.0-862.14.4.el7.x86_64
8 verbose argv "/home/user/Downloads/node-v10.14.0-linux-x64/bin/node" "/home/user/Downloads/node-v10.14.0-linux-x64/bin/npm" "audit"
9 verbose node v10.14.0
10 verbose npm  v6.5.0
11 error code EINVALIDTAGNAME
12 error Invalid tag name "[object Object]": Tags may not have any characters that encodeURIComponent encodes.
13 verbose exit [ 1, true ]

If this would happen to only one project - but actually it does indeed happen to all projects that I've tried (~70). There is an internal registry, but I've both removed the local .npmrc and the one in home. Also the error I was getting then was a different one.

Is this a bug or am I doing something wrong?

1 Answers

Not positive if this is the exact issue the author is hitting, but I ran into this error when I copy/pasted the contents of my package.json into package-lock.json. As I was searching through the JS stack trace, I realized that those files have different object formats and are not interchangeable.

This is likely your issue if npm install works fine, but npm ci and npm audit are failing with the above error.

Related