Reputation: 125
I create a react project using create-react-app. And in order to pack it to run elsewhere, i use Docker with this config file:
My 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
When i run my app inside docker using docker build . -t name_repo
, the build stops at step 7/8 (npm run transpile) where i need to transpile the codes using babel (babel-preset-env and babel-preset-react-app) and got this error:
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"
},
...
Upvotes: 2
Views: 1105
Reputation: 86
I think Node_env is unlikely able to find the present name in the production configuration file . I would suggest please check all the parameters once again and use SET NODE_ENV =production
Upvotes: 3