Reputation: 535
I tried deleting the node_modules folder, but I'm still getting the error. It was working fine, but suddenly has started throwing this error.
It's a react app, if that helps.
Docker file
## Stage 0, "builder", based on Node.js, to build and compile the frontend
# base image
FROM node:alpine as builder
# set working directory
WORKDIR /app
# add `/app/node_modules/.bin` to $PATH
ENV PATH /app/node_modules/.bin:$PATH
## add app
COPY . /app
# delete node modules to fix discrepancies
RUN rm -rf node_modules/
#RUN npm install && npm audit fix && npm audit fix --force && npm install
RUN npm install -g [email protected] && npm install && npm audit fix
RUN npm run build
## Stage 1, "deployer", use nginx to deploy the code
## start app
FROM nginx:alpine
RUN rm -rf /usr/share/nginx/html/*
COPY --from=builder /app/build /usr/share/nginx/html/
RUN rm /etc/nginx/conf.d/default.conf
COPY ./nginx-custom.conf /etc/nginx/conf.d/default.conf
console errors
npm notice
npm notice New patch version of npm available! 7.0.2 -> 7.0.3
npm notice Changelog: <https://github.com/npm/cli/releases/tag/v7.0.3>
npm notice Run `npm install -g [email protected]` to update!
npm notice
npm ERR! code EXDEV
npm ERR! syscall rename
npm ERR! path /usr/local/lib/node_modules/npm
npm ERR! dest /usr/local/lib/node_modules/.npm-i9nnxROI
npm ERR! errno -18
npm ERR! EXDEV: cross-device link not permitted, rename '/usr/local/lib/node_modules/npm' -> '/usr/local/lib/node_modules/.npm-i9nnxROI'
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2020-10-23T16_47_42_554Z-debug.log
The command '/bin/sh -c npm install -g [email protected] && npm install && npm audit fix' returned a non-zero code: 238
Upvotes: 2
Views: 2813
Reputation: 51
Sorry, not enough rep to comment.
I actually ran into similar issues as well. Node's been updated which has bumped the npm version up to 7+, which seems to be causing people issues. My solution until I can fully flesh out the issues has been to version lock my Node/NPM within my container build.
FROM node:14.14-alpine3.11
is the instruction I'm using, keeps me at some 6.x.x version to keep my builds working.
Upvotes: 0
Reputation: 21
I ran into the same issue. Since your base image is node, npm should already be globally installed. There is no need to run npm install -g [email protected]
and still be able to execute all npm related items afterwards.
Upvotes: 2