Docker-node: npm 5.3.0 in node 8

Created on 6 Jul 2017  Â·  13Comments  Â·  Source: nodejs/docker-node

Just opening this to discuss npm 5 upgrade due to its recent important release. It fixes quite a few serious bugs in npm install, which used to break the contents node_modules directory between the commits.

I guess I'm not the only person interested to know when to finally uncomment node_modules caching in CI and thus get some speed boost and reduce the load on the public registry :–)

question

Most helpful comment

You can do this as a workaround:

FROM node:8

RUN yarn global add npm

RUN npm --version

It works with alpine as well.

All 13 comments

Official policy is to not update it, as it's bundled with node itself. So normally we'd wait until the next node update. Not sure if we want to make an exception or not for this one?
(npm cannot self-update itself, #449, so it's a bit convoluted to update it)

https://github.com/nodejs/docker-node/blob/8cbad29a9f652f974a59daf7dd4743b92c322c3b/CONTRIBUTING.md#version-updates

Yeah, it might deserve some kind of an exception because of the number of problems in npm 5.0.x. Does node have to get a minor version bump to cause npm's minor version bump? Or can node 8.1.3 → 8.14 upgrade imply npm 5.0.3 → 5.1.0? __UPD__ 5.3.0

I really think it would be a great idea because trying:

FROM node:8.1.3-alpine
RUN npm install -g [email protected]
CMD npm --version

Building the image

Sending build context to Docker daemon  3.072kB
Step 1/3 : FROM node:8.1.3-alpine
 ---> 52102cf589d3
Step 2/3 : RUN npm install -g [email protected]
 ---> Running in a8c48c3ec1c5
<omitted npm install logs>
+ [email protected]
added 27 packages, removed 16 packages and updated 47 packages in 12.299s
npm info ok
 ---> ce5a3bfcb473
Removing intermediate container a8c48c3ec1c5
Step 3/3 : CMD npm --version
 ---> Running in d3fffdc1a709
 ---> 9f08ed524fa2
Removing intermediate container d3fffdc1a709
Successfully built 9f08ed524fa2

Running the container using this image

module.js:487
    throw err;
    ^

Error: Cannot find module 'semver'
    at Function.Module._resolveFilename (module.js:485:15)
    at Function.Module._load (module.js:437:25)
    at Module.require (module.js:513:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/unsupported.js:2:14)
    at Module._compile (module.js:569:30)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:503:32)
    at tryModuleLoad (module.js:466:12)
    at Function.Module._load (module.js:458:3)

Yes, as mentioned, this is known. #449

You can do this as a workaround:

FROM node:8

RUN yarn global add npm

RUN npm --version

It works with alpine as well.

Are we good to close this out? It's an npm issue that I'm assuming will get fixed in a future v8.1 update.

Hi @chorrell, do you mean 8.1.5? Just tried 8.1.4 – npm is still 5.0.3

docker run -it node:8.1.4 /bin/sh
node --version
# v8.1.4
npm --version
# 5.0.3

Might be worth keeping this issue open until 5.1.0+ is out there – some people might be subscribed to updates and are waiting for a moment when they can update their CI scripts :–) node_modules can't be cached between the build in npm 5.0.* because of a bug.

No, I wasn't thinking of a specific v8.x.x release.

I did a quick search and I think this would be a better issue to track:

https://github.com/nodejs/node/pull/14163

Looks like npm v5.2.0 is due to land (I think) in v8.2.0:

https://github.com/nodejs/node/pull/13744

+1 on closing. Our policy is to to not track npm releases, just use what's bundled in node.

If someone really wants to upgrade npm, they can just do npm i -g npm (in general, right now that's broken).

nodejs/node#14235

Node 8.2.0 is out, with npm 5.3.0 bundled! Hopefully, it would be published to Docker Hub soon.

A PR to docker hub is up: https://github.com/docker-library/official-images/pull/3210

After that's merged it'll generally appear in 1-2 hours

It's out now.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

marciomsm picture marciomsm  Â·  4Comments

kingjerod picture kingjerod  Â·  5Comments

sam-github picture sam-github  Â·  4Comments

danbev picture danbev  Â·  3Comments

frankbaele picture frankbaele  Â·  3Comments