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"
},
...
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
Related
I have a web app that uses Express backend and React frontend. The heroku-postbuild script in my package.json is as follows:
"heroku-postbuild": "npm run build && cd frontend && npm install && npm run build"
When I git push heroku master all seems to be fine until I get:
"Failed at the honeyman-designs#1.0.0 heroku-postbuild script."
this is the script:
"scripts": {
"start": "nodemon --watch backend --exec babel-node backend/server.js",
"build": "del -rf dist && babel backend -d dist",
"heroku-postbuild": "npm run build && cd frontend && npm install && npm run build"
},
The script inside frontend is:
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
I'm using Windows 10 as my OS.
My Procfile contains:
web: node dist/server.js
I'm not too sure what I'm doing to get this error if anybody can help it would be appreciated.
I am trying to deploy nextjs based project on AWS EBS, but it is not able to run script "npm run-script build" on server, by this it makes nextjs based build package folder and can run app. here my json.
"scripts": {
"dev": "node server.js",
"build": "next build",
"start": "cross-env NODE_ENV=production node server.js"
}
when I deployed my app on server it gives following error.
Error: Could not find a valid build in the '/var/app/current/.next' directory! Try building your app with 'next build' before starting the
server.
I need to run command "npm run-script build" before running app on server, but dosen't aware how to achieve this
simply we can run multiple commands at a time.
"scripts": {
"dev": "node server.js",
"build": "next build",
"start": "npm-run-script-build && cross-env NODE_ENV=production node server.js"
}
I want to run the to build commands (clienr and server) in one npm run commands.
So on my package.json scripts section I added this line:
"build-all": "ng build --prod && ng run web-app:server",
The problem occurs when I run this commands: npm run build-all --configuration=qa.europe.
The configuration is loaded when I run each commands separately but not when I run the above commands.
Any ideas?
You can try this.
"scripts": {
"start:production": "npm install && npm run build && npm run start:prod",
"start:prod": "cross-env NODE_ENV=production node server",
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
}
npm run start:production it will run "start:production" & "start:prod" both scripts
You can try to use postinstall, it will look as next:
"scripts": {
"start": "ng run web-app:server",
"postinstall": "ng build --prod --configuration=qa.europe",
}
So after npm install, the build of your UI starts. And after that will start your server.
I want to run a command like: npm run start:dev to make my node server runs but after webpack finished building bundles.
My current npm scripts are:
"scripts": {
"start": "node server/server.js",
"start:dev": "npm run build:prod & npm start",
"lint": "eslint *",
"build:dev": "webpack",
"build:prod": "webpack -p --env production",
"dev-server": "webpack-dev-server",
"test": "cross-env NODE_ENV=test jest --config=jest.config.json"
},
The current command will kick both operations together.
Typo: you don't actually want to use &, you want &&:
"start:dev": "npm run build:prod && npm start",
A single ampersand will background the run:build job and cause start to run concurrently.
Anyone know how to get node AWS beanstalk to run npm run build command after its does its npm install.
I have the following scripts in my package.json but it doesn't seem to run the build or the start command just the install
"scripts": {
"build": "cross-env NODE_ENV=production webpack --config ./webpack/webpack.prod.config.js --progress --colors",
"start": "node server/app.js",
"dev": "nodemon server/app.js"
},