Error: 在 Dockerfile 中运行 npm run build 期间无法解析 ‘dns’

huangapple go评论57阅读模式
英文:

Error: Can't resolve 'dns' during npm run build in Dockerfile

问题

我在Dockerfile的npm run build过程中遇到了以下dns错误。

ModuleNotFoundError: Module not found: Error: Can't resolve 'dns' in '/reactProj/node_modules/ioredis/built/cluster'

在package.json中,dns被配置为指向一个模拟文件。

"dns": "file:./lib/__mocks__/dns"

对于这个问题,我应该做什么更改?谢谢!

英文:

I'm getting the following error with dns during npm run build in Dockerfile.

ModuleNotFoundError: Module not found: Error: Can't resolve 'dns' in '/reactProj/node_modules/ioredis/built/cluster'

dns is configured in the package.json to point to a mock file.

    "dns": "file:./lib/__mocks__/dns",

What change should I be doing for this?

Dockerfile for ref:

FROM node:16
ENV NODE_ENV production
WORKDIR /reactProj
COPY ./package.json /reactProj
RUN npm install
COPY . .
RUN npm run build

Thanks in advance.

答案1

得分: 1

这通过从Dockerfile中移除以下内容来解决了:

NODE_ENV production

npm run build命令已经在脚本中设置了相同的内容。

英文:

This got fixed by removing the following from Dockerfile

NODE_ENV production

npm run build command from scripts already sets the same.

huangapple
  • 本文由 发表于 2023年4月4日 12:38:17
  • 转载请务必保留本文链接:https://go.coder-hub.com/75925558.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定