locally, i start my app using the following commands:
cd react-web
sudo npm run postinstall
export REACT_APP_CUSTOMER_ENVIRONMENT=envvariable
npm start
So, now i want to push this live through heroku. BUT, i need to set the start scripts in my package.json
so i have two package.json, one in the root directory, and one in react-web.
in the root directory, i wrote this start-script:
"scripts": {
"test-web": "cd react-web && npm test && cd ..",
"test": "npm run test-web",
"start": "cd react-web && export REACT_APP_CUSTOMER_ENVIRONMENT=gianlucaherokutest && npm start"
},
and in the react-web package.json, this:
"scripts": {
"start": "node checkEnvironmentForBuild && react-app-rewired start",
"build": "node checkEnvironmentForBuild && react-app-rewired build",
"deploy": "aws s3 sync build/ s3://YOUR_S3_DEPLOY_BUCKET_NAME --delete",
"postdeploy": "aws cloudfront create-invalidation --distribution-id YOUR_CF_DISTRIBUTION_ID --paths '/*' && aws cloudfront create-invalidation --distribution-id YOUR_WWW_CF_DISTRIBUTION_ID --paths '/*'",
"postinstall": "npm link ../shared",
"test": "node checkEnvironmentForBuild && react-app-rewired test",
"eject": "react-scripts eject"
},
can someone give me some advice on why it isn't working? When I run the app using everything above, it gives me this error:
2021-04-19T21:12:11.796818+00:00 app[web.1]: FATAL ERROR: MarkCompactCollector: young object promotion failed Allocation failed - JavaScript heap out of memory
any ideas?
Related
Failed to migrate: buildpacks from Heroku to Nixpacks
I need help I can't do the migration of my front end projects it doesn't compile and gives an error.
My Heroku buildpacks:
This script works correctly to generate the application on Heroku and Vercel, but I can't install it with the Nixpacks package. Can someone tell me what is wrong with the scripts?
"scripts": {
"dev": "react-scripts start",
"start": "serve -s build",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject",
"heroku-postbuild": "npm run build",
"install:clean": "rm -rf node_modules/ && rm -rf package-lock.json && npm install && npm start",
"compile:scss": "node-sass src/assets/scss/light-bootstrap-dashboard-react.scss src/assets/css/light-bootstrap-dashboard-react.css",
"minify:scss": "node-sass src/assets/scss/light-bootstrap-dashboard-react.scss src/assets/css/light-bootstrap-dashboard-react.min.css --output-style compressed",
"map:scss": "node-sass src/assets/scss/light-bootstrap-dashboard-react.scss src/assets/css/light-bootstrap-dashboard-react.css --source-map true",
"build:scss": "npm run compile:scss && npm run minify:scss && npm run map:scss"
},
Error:
Using Nixpacks
Nixpacks build failed
If someone could help me, so as not to leave the railway.
The Heroku buildpacks are finally leaving Railway forever on Novermber 14th.
Moving From Heroku to Railway
I really appreciate any help, I'm new to this type of development
In railway settings>general>root directory> name of the directory where you do mpn start
&&
package.json>"scripts">"start": "nodemon src/app.js"
I have deployed my simple React app to Heroku - https://projectslist.herokuapp.com It works just fine except for the server part which doesn't work at all. I've seen the logs and it says that my only server method - /sendmail - returns error 404. How can i fix this problem? I suppose that I should edit something in package.json file but I'm not sure what I should change.
Here's my github repo - https://github.com/VasVV/Projects-list
Try putting your server files in the root directory folder and everything else in a client folder within the root:
1.) Put your server.js into the root directory
2.) Add these commands to your root package.json...
"scripts": {
"client-install": "npm install --prefix client",
"start": "node server.js",
"server": "nodemon server.js",
"client": "npm start --prefix client",
"dev": "concurrently \"npm run server\" \"npm run client\"",
"heroku-postbuild": "NPM_CONFIG_PRODUCTION=false npm install --prefix client && npm run build --prefix client"
},
"proxy": "http://localhost:4242/"
3.) Create a client folder and put your src and public folders in it.
4.) Add these commands to your client folders package.json...
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
Your file structure from root should look like this:
Root
client
Public
Src
package.json
server.js
package.json
5.) Move all your server-related stuff into the root folder, that way, you don't have to cd into any nested folders.
Add a Procfile to your root folder that says something like:
web: node server/index.js -port 8000
And a small addition to the scripts part of your package.json that tells Heroku that once it's fetched all the dependencies for your project it should build it, although that may not be necessary now.
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject",
"heroku-postbuild": "npm run build"
},
when the status is online i am running the port on 8014 its still not running
when i use pm2 start tools/srcServer.js
"scripts": {
"prestart": "babel-node tools/startMessage.js",
"start": "npm-run-all --parallel test:watch open:src",
"open:src": "babel-node tools/srcServer.js",
"test": "mocha --reporter progress tools/testSetup.js \"src/**/*.test.js\"",
"test:watch": "npm run test -- --watch",
"clean-dist": "npm run remove-dist && mkdir dist",
"remove-dist": "node_modules/.bin/rimraf ./dist",
"build:html": "babel-node tools/buildHtml.js",
"prebuild": "npm-run-all clean-dist test build:html",
"build": "babel-node tools/build.js",
"postbuild": "babel-node tools/distServer.js"
}
I am running the node with npm start I need to run the node to run run the server forever.
I tried using the command "forever start -c "npm start" ./" its not showing
To run npm start from pm2 you can run pm2 start npm -- start. This will run any command that is written within package.json start section.
Why don't you try to use PM2 (Node process manager: http://pm2.keymetrics.io/)?
I use the following project which use webpack
https://github.com/Hashnode/mern-starter
I want to deploy it (to prod) i get error
Error: Cannot find module './dist/manifest.json'
This error is coming from https://github.com/Hashnode/mern-starter/blob/master/index.js
But I dont see the dist folder in the project, why, and how should I build it?
I believe that the Dist folder should be created during the build time (manification etc) so how should I trigger it ?
This is the package.json
{
"name": "mern-starter",
"version": "2.0.0",
"description": "Boilerplate project for building Isomorphic apps using React and Redux",
"scripts": {
"test": "cross-env NODE_ENV=test PORT=8080 MONGO_URL=mongodb://localhost:27017/mern-test node_modules/.bin/nyc node --harmony-proxies node_modules/.bin/ava",
"watch:test": "npm run test -- --watch",
"cover": "nyc npm run test",
"check-coverage": "nyc check-coverage --statements 100 --branches 100 --functions 100 --lines 100",
"start": "cross-env BABEL_DISABLE_CACHE=1 NODE_ENV=development nodemon index.js",
"start:prod": "cross-env NODE_ENV=production node index.js",
"bs": "npm run clean && npm run build && npm run build:server && npm run start:prod",
"build": "cross-env NODE_ENV=production webpack --config webpack.config.prod.js",
"build:server": "cross-env NODE_ENV=production webpack --config webpack.config.server.js",
"clean": "rimraf dist",
"slate": "rimraf node_modules && npm install",
"lint": "eslint client server"
},
I think that the start:prod should trigger it in the webpack but
its not happing ...any idea ?
As per the comments and the documentation:
Building the dist folder is done either via npm run bs or npm run build && npm run build:server (which is what npm run bs executes).
Starting the production build should be done via npm run start:prod (or by copying the commands from the package.json file: cross-env NODE_ENV=production node index.js)
My package.json
"scripts": {
"lint": "eslint src tools test",
"test": "npm run lint && mocha --compilers js:babel/register",
"clean": "babel-node --eval \"require('./tools/clean')().catch(err => console.error(err.stack))\"",
"build": "babel-node --eval \"require('./tools/build')().catch(err => console.error(err.stack))\"",
"start": "babel-node --eval \"require('./tools/start')().catch(err => console.error(err.stack))\"",
"deploy": "babel-node --eval \"require('./tools/deploy')().catch(err => console.error(err.stack))\""
}
When I do
npm run build
having syntax error in any file of the application. I can see the console error output in console but the build itself returns exit code 0. How can I fail the whole build?
(throw - not working)