[英]Transpile using babel-preset-env without ejecting from create-react-app
我使用create-react-app创建一个react项目。 为了将其打包以在其他地方运行,我将Docker与以下配置文件结合使用:
我的Dockerfile
FROM node
COPY package.json .
RUN npm install
COPY . .
RUN npm run build
RUN npm run transpile
CMD PORT=$PORT npm run start:prod
当我使用docker build . -t name_repo
在docker内部运行我的应用程序时docker build . -t name_repo
docker build . -t name_repo
,构建停止在步骤7/8(npm run transpile),在这里我需要使用babel(babel-preset-env和babel-preset-react-app)来转换代码,并得到以下错误:
的package.json:
...
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject",
"transpile": "NODE_ENV=production babel src --out-dir transpiled --presets env,react-app",
"start:prod": "NODE_ENV=production node server.js"
},
...
我认为Node_env不太可能在生产配置文件中找到当前名称。 我建议请再次检查所有参数,然后使用SET NODE_ENV = production
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.