Home > Net >  How to install @swc/core-linux-musl on windows, to make it work in docker container?
How to install @swc/core-linux-musl on windows, to make it work in docker container?

Time:01-20

I'am working on windows. I docernize Next.js with Typescript app. Here is my dockerfile:

FROM node:alpine

# create directory where our application will be run
RUN mkdir -p /usr/src
WORKDIR /usr/src

# copy our files into directory
COPY . /usr/src

# install dependences
RUN npm install

EXPOSE 3000
ENTRYPOINT ["npm", "run" ,"dev"]

During development I bind host catalogue to container by --mount type=bind,source=d:/apps/library.next.js/,target=/usr/src. When I start container I get error: error - Failed to load SWC binary for linux/x64, see more info here: https://nextjs.org/docs/messages/failed-loading-swc.

That's fine, I understand error and know what to do. To fix this I need to install @swc/cli @swc/core @swc/core-linux-musl, but I can't doing it because npm complain:

ERR! code EBADPLATFORM npm
ERR! notsup Unsupported platform for @swc/[email protected]: wanted {"os":"linux","arch":"x64"} (current: {"os":"win32","arch":"x64"})

How to install it on windows, or how to change docker setup to make it work? I must install it locally then it will be linked (by binding !) into container.


My workaround for now is to get into container by docker exec -it <id> /bin/sh then manually type npm install -save-dev @swc/cli @swc/core @swc/core-linux-musl. But doing that every time I recreate container is annoying.

CodePudding user response:

The docs state: The -f or --force will force npm to fetch remote resources even if a local copy exists on disk. And it should be in the docs v6 legacy, the one you posted and v8 version. (See the section after --package-lock-only. It comes with an example npm install sax --force). So, you shouldn't have issues with that every time your container is recreating.

  •  Tags:  
  • Related