-
Notifications
You must be signed in to change notification settings - Fork 66
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
Update Node and npm to a more recent version #123
Comments
@derberg do you know if there is any issue/blocker we should know about that stop us from moving forward on updating Node and npm? |
in generator all should be fine "in theory" as issues for version 14 were fixed few months ago. I'm more interested in how you see it? switching from 14 to 16 or rather test on both, IMHO it should be both |
ping @smoya |
We use Lockfile version 2, and it is only available on npm v7 or greater. So yes, we drop support for node versions lower than 16 (it doesn't mean our software won't work on those versions, but we just don't give support). |
Lockfile v2 will still work with older npm:
Version of used Node should not depend on version of used npm. Many people in Nodejs ecosystem do not even use npm but yarn or pnpm |
Yeah, it's true, but in our case with |
As @magicmatatjahu mentioned in the comment above, this is not 100% right. And that's the whole reason why this issue is opened. You can read the long version and will understand the problems we can introduce without knowing about them. |
brace yourself, a stupid question is approaching 😄 I still think that the node version and npm version discussion should be split. I understand that there are some strange issues when installing with so why would we force node 16 on all the projects, just because in I think it is ok if we just make that all the pipelines use npm > 6, through setup-node action that we already use (they do not support it yet actions/setup-node#529) or by adding a specific step to install given npm first. And in Thoughts? or am I missing something? but from description and comments I do not identify any issues with the runtime, only installation |
Each NodeJS release is bundled with a particular NPM version. Agree you can change that, but using too older or too newer versions of NPM could cause issues as well. That's why, NodeJS 15 is the minimum version for using NPM 8. In fact, I would recommend using NodeJS 16 because is a LTS. |
There is an extra issue to consider here. Keeping |
Another option would be to enforce all projects to stay with Node v14 + NPM 6, meaning |
I totally get it. But I do not think it is a common practice/knowledge that "if you decide to use
you are right, but not the release workflow, but the bump workflow. Release workflow do not make changes to repo, the
Ok, so the lowest LTE is
What I think we agree on:
What we need to agree on:
After all these discussions, I personally think that the best practice is if maintainers work always on lowest LTS, not highest |
While trying to upgrade Modelina for dotnet-nats-template and ts-nats-template I ran into some issues where the dependencies didn't get installed correctly, and I was using node @magicmatatjahu then suggested to try and upgrade and use a newer lockfile version, so I upgraded to npm So using lockfile v1 for node 14, might not work going forward. At least when it comes to similar scenario 🧐 I will get back to you if I encounter any more issues with dependencies... |
This issue has been automatically marked as stale because it has not had recent activity 😴 It will be closed in 120 days if no further activity occurs. To unstale this issue, add a comment with a detailed explanation. There can be many reasons why some specific issue has no activity. The most probable cause is lack of time, not lack of interest. AsyncAPI Initiative is a Linux Foundation project not owned by a single for-profit company. It is a community-driven initiative ruled under open governance model. Let us figure out together how to push this issue forward. Connect with us through one of many communication channels we established here. Thank you for your patience ❤️ |
TL;DR;
Lockfile version 2 is available starting at npm v7, However I think we could update it even to a more recent version.
For example, Node v16, that includes npm v8).
npm install
command here should be replaced bynpm ci
so we avoid side effects (no modification of package-lock.json).Any strong reason to not do this?
Long version if you are not very convinced
The following is a real use case of a bug in the produced image. It took me like an hour to figure out the "bug" (thanks to @magicmatatjahu for pairing!).
The very first Docker image of server-api was built and pushed to Docker Hub by our GH workflow action if-nodejs-release.yml.
Unfortunately, after trying to deploy it to a K8s cluster, we found out that the container was failing due to a missing node module:
Error: Cannot find module '@babel/core'
. By pulling the same image locally, we discarded the problem was in K8s but in the image itself.The surprise is that, whenever that image is built locally (e.g. in my computer), the container works like a charm.
But why?
After diving (literally, using dive tool) into both Docker images (the one created by CI and the one created by myself locally), I noticed there was a big difference on a particular Docker layer. In particular, in the one created by
COPY package* ./
.As you can see, the
package-lock.json
filesize differs. The one created by CI is much smaller (554 kB VS 1.2 MB).After reading both files, I noticed that the
package-lock.json
from the image created by CI was a version 1 ("lockfileVersion": 1
), however both the one created locally and the one available in the repository source code are version 2 ("lockfileVersion": 2
).But how can be possible if dependencies are installed inside docker? See Dockerfile. Could be a bug with Docker? The answer is no.
Dependencies were not built at the time
RUN npm ci
was executed, by way before. In particular, in the GH workflow action that precedes this. Inside Docker image we only runnpm ci
, which is intended for just using thepacakge-lock.json
as the list of dependencies to install without modification.This line is running a
npm install
command, so all dependencies are installed. Is the GH action running an oldnpm
version that doesn't support lockfile version 2? Well, considering that the image where we run isubuntu-latest
, thenpm
version should be8.1.2
(according to this). But we are not using that NPM (nor node) executable, but rather the one installed in the previous step, which is:.
The reason why the npm lockfile version is 1 in CI is because
npm install
that ran in the workflow with NPM v6.14.15 doesn't understand lockfile version 2 fully, so it literally tries to do the best (which seems it's not the best for us). As the warning says:Due to that missing dependency (
@babel/core
) that npm couldn't install, the app is broken.Related issues
npm install
. parser-js#427The text was updated successfully, but these errors were encountered: