英文:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论