Failed to migrate: buildpacks from Heroku to Nixpacks - javascript

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"

Related

'.' is not recognized as a internal command (React Package.Json)

I cannot deploy my react project on github pages because the change that I did in my package json shows the error below:
I just added inside of Scripts: publicar
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject",
"publicar": "npm run build && ./node_modules/bin/gh-pages -d build"
},
I'm using '.' because i need to access the node_modules that is located in a different place that my package json.
When I execute the command 'npm run publicar' shows me this error:
'.' is not recognized as a internal command
When I execute the 'npm run publicar' should not show me errors and should show 'published'
npm runs with node_modules/bin in its PATH. You should just be able to use gh-pages the same way you use react-scripts.
I would also advise using a pre-script instead of chaining commands
"prepublicar": "npm run build",
"publicar": "gh-pages -d build"

npm ERR! code EINVALIDTAGNAME in installing a package

i am trying to install a package in my react app
but i get this error
$ npm install xlsx
npm ERR! code EINVALIDTAGNAME
npm ERR! Invalid tag name "react-scripts start": Tags may not have any characters that encodeURIComponent encodes.
this is my scripts in package.json
"scripts": {
"start": "react-scripts --openssl-legacy-provider start",
"build": "react-scripts --openssl-legacy-provider build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
version of react is 17
and my node version is 17
but app created by a different version of node
i don't know what to do
it was becuase the version of my npm
i downgrade it and problem solved
npm install -g npm#6.14.14

Connecting React frontend and Node.js backend at Heroku

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"
},

setting start scripts in package.json

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?

How to get npm run script run the build:style script when CSS files are updated?

In my package.json I have run scripts that look like:
"scripts": {
"build:style":"tailwind build src/styles/index.css -o src/styles/tailwind.css",
"start": "npm run build:style && react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
I'm using this tailwindcss framework for CSS, and it uses PostCSS to update the CSS.
Currently if I update my CSS npm doesn't run the build, so my CSS changes are not visible until I stop and re-rerun:
npm run start
Is there a way for npm to watch the CSS files, and when changed also run the build:style command?
Unfortunately, I don't believe Tailwinds has a 'watch' feature. I believe one workaround would be to install the watch package.
npm install watch
You have a lot of scripts going on and without knowing how you've integrated PostCSS and the likes, it's tough to know exactly what to do. One option would be to create a new script that takes advantage of the new watch node package.
"scripts": {
"build:style":"tailwind build src/styles/index.css -o src/styles/tailwind.css",
"start": "npm run build:style && react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject",
"watch": "watch 'npm run start'"
},
If that doesn't work, check out the blog below. It uses the same methodology, but may have insight that could help you figure it out!
https://flaviocopes.com/tailwind-setup/

Categories

Resources