btholt / complete-intro-to-containers

The Complete Intro to Containers! As taught on Frontend Masters.
https://frontendmasters.com/courses/complete-intro-containers/
Other
941 stars 187 forks source link

[Lessons (more-complicated-nodejs-app)] - Error: RUN npm ci #82

Open JPaezMin opened 1 year ago

JPaezMin commented 1 year ago

When in the "Add dependencies to a node.js App" class after completing the Dockerfile setup I'm getting the following error related to the "RUN npm ci" line within the Dockerfile file:


[5/5] RUN npm ci:

9 0.259 npm ERR! Cannot read property '@hapi/hapi' of undefined

9 0.263

9 0.263 npm ERR! A complete log of this run can be found in:

9 0.263 npm ERR! /home/node/.npm/_logs/2023-04-28T11_12_43_884Z-debug.log


Don't really know if this is related to a previous issue ref "[Lessons (more-complicated-nodejs-app)] - Error: prettyPrint option is no longer supported". In any case I have changed versions on both the package-lock.json and package.json file but still getting the same error.

Ibarra11 commented 1 year ago

The issue with this is that the container and your computer are running different version of node, which produces incompatible lockfileVersions for package-lock.json. What I did was just update the node version on docker to one that is compatible with the one on my system. I will leave the stack overflow question that helped me. https://stackoverflow.com/questions/76253884/npm-ci-command-failing-with-cannot-read-property-angular-animations-of-undef

ctgao commented 9 months ago

Just encountered this error as well, but I had a different solution than above.

Since I'm on NPM v9, but the container is on NPM v6, the lockfile automatically generated by v9 is lockfile v3, incompatible with NPM v6 which uses lockfile v1.

The fix: npm i --lockfile-version 1 --package-lock-only which generates the lockfile v1 (and only the lockfile so you don't have to delete the "node_modules" folder every time).