Repository navigation
Closed
Labels
Bugthing that needs fixingNeeds Triageneeds review for next stepsRelease 7.xwork is associated with a specific npm 7 release
Milestone
Description
Current Behavior:
When executing npm version {version} or even npm version from-git in my CI pipeline I get the following error:
0 verbose cli [ '/usr/local/bin/node', '/usr/local/bin/npm', 'version', 'from-git' ]
1 info using npm@7.0.3
2 info using node@v15.0.1
3 timing config:load:defaults Completed in 2ms
4 timing config:load:file:/usr/local/lib/node_modules/npm/npmrc Completed in 1ms
5 timing config:load:builtin Completed in 1ms
6 timing config:load:cli Completed in 3ms
7 timing config:load:env Completed in 2ms
8 timing config:load:file:/builds/open-source/javascript/eslint-config/.npmrc Completed in 0ms
9 timing config:load:project Completed in 1ms
10 timing config:load:file:/root/.npmrc Completed in 2ms
11 timing config:load:user Completed in 2ms
12 timing config:load:file:/registry.npmjs.org/:_authToken=xxxx
python=/usr/bin/python3 Completed in 0ms
13 timing config:load:global Completed in 0ms
14 timing config:load:cafile Completed in 1ms
15 timing config:load:validate Completed in 1ms
16 timing config:load:setUserAgent Completed in 1ms
17 timing config:load:setEnvs Completed in 1ms
18 timing config:load Completed in 15ms
19 verbose npm-session xxxx
20 timing npm:load Completed in 26ms
21 timing command:version Completed in 24ms
22 verbose stack TypeError: Cannot read property 'trim' of undefined
22 verbose stack at clean (/usr/local/lib/node_modules/npm/node_modules/semver/functions/clean.js:3:27)
22 verbose stack at module.exports (/usr/local/lib/node_modules/npm/node_modules/libnpmversion/lib/version.js:38:24)
22 verbose stack at module.exports (/usr/local/lib/node_modules/npm/node_modules/libnpmversion/lib/index.js:23:10)
22 verbose stack at async version (/usr/local/lib/node_modules/npm/lib/version.js:40:21)
23 verbose cwd /builds/open-source/javascript/eslint-config
24 verbose Linux 5.4.0-37-generic
25 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "version" "from-git"
26 verbose node v15.0.1
27 verbose npm v7.0.3
28 error Cannot read property 'trim' of undefined
29 verbose exit 1
Expected Behavior:
The npm package version should be updated to defined version.
Steps To Reproduce:
I use the following docker image (which is built from my ci as well): https://github.com/orgs/jitesoft/packages/container/package/node
The following package is the latest I tried to build: https://github.com/jitesoft/eslint-config
Environment:
OS: Alpine linux
Node: 15.0.1
NPM: 7.0.3
Metadata
Metadata
Assignees
Labels
Bugthing that needs fixingNeeds Triageneeds review for next stepsRelease 7.xwork is associated with a specific npm 7 release
Activity
ljharb commentedon Oct 31, 2020
Can you try on npm v7.0.7?
Johannestegner commentedon Oct 31, 2020
Will do!
Edit: Takes a couple of more minutes, want to use the same image to be sure it's the same environment :P
Johannestegner commentedon Oct 31, 2020
Alright, finally got it up and running with the correct version of npm. Still the same issue though.
I find it odd that I experience this, due to the fact that I'm quite sure that thousands of people do this every day, and I don't use any odd commands really.
If you can't reproduce it, let me know and I'll set up a small reproducible case for you! :)
Johannestegner commentedon Oct 31, 2020
Easiest way to test it is:
Node is built from source and if you wish to see the build procedure it can be found here:
https://github.com/jitesoft/docker-node-base/blob/master/.gitlab-ci.yml#L115
Just let me know if you need any more info or anything else.
Johannestegner commentedon Oct 31, 2020
Just updated my windows host npm and tested another package, it gave the same issue.
Johannestegner commentedon Oct 31, 2020
I must say that this a huge issue, as I have about 20 packages which are deployed quite often (weekly auto, and more often manually), each of which uses the same CI pipeline, and without the availability of the version command, they are all broken.
I guess I could change the base pipeline to use sed or similar to change the version, but one would expect the command to work as intended :/
shadowspawn commentedon Nov 1, 2020
I reproduced locally on Mac with your repo. I noticed the
package.jsonin your example repository does not have a version field. Adding one eliminates the error, so that may be a potential work-around.The
package.jsondocumentation says:https://docs.npmjs.com/cli/v6/configuring-npm/package-json#version
Johannestegner commentedon Nov 1, 2020
Ah tyvm @shadowspawn, that will be easy to fix! :)
isaacs commentedon Nov 3, 2020
Going to handle it over on libnpmversion. Thanks for the report! npm/libnpmversion#4
libnpmversion@1.0.7