Nodejs app with Heroku failing on "react-scripts: Permission denied" - node.js

I am trying to push my app to Heroku, but I am getting an error when it gets to the heroku postbuild script:
remote: > NPM_CONFIG_PRODUCTION=false npm install --prefix client && npm run build --prefix client
remote:
remote: audited 905058 packages in 15.807s
remote: found 0 vulnerabilities
remote:
remote:
remote: > client#0.1.0 build /tmp/build_b7466d5902dcde0a3dc95258046c08c6/client
remote: > react-scripts build
remote:
remote: sh: 1: react-scripts: Permission denied
remote: npm ERR! code ELIFECYCLE
remote: npm ERR! errno 126
remote: npm ERR! client#0.1.0 build:react-scripts build
remote: npm ERR! Exit status 126
remote: npm ERR!
remote: npm ERR! Failed at the client#0.1.0 build script.
remote: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
remote:
remote: npm ERR! A complete log of this run can be found in:
remote: npm ERR! /tmp/npmcache.CXg0t/_logs/2019-10-17T19_19_39_823Z-debug.log
remote: npm ERR! code ELIFECYCLE
remote: npm ERR! errno 126
remote: npm ERR! safety-influence#1.0.0 heroku-postbuild:NPM_CONFIG_PRODUCTION=false npm install --prefix client && npm run build --prefix client
remote: npm ERR! Exit status 126
remote: npm ERR!
remote: npm ERR! Failed at the safety-influence#1.0.0 heroku-postbuild script.
remote: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
remote:
remote: npm ERR! A complete log of this run can be found in:
remote: npm ERR! /tmp/npmcache.CXg0t/_logs/2019-10-17T19_19_39_835Z-debug.log
Here is my package.json folder on the server side:
{
"name": "safety-influence",
"version": "1.0.0",
"description": "",
"engines": {
"node": "12.3.1"
},
"main": "server.js",
"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"
},
"author": "David Jaenike",
"license": "ISC",
"dependencies": {
"bcryptjs": "^2.4.3",
"body-parser": "^1.19.0",
"concurrently": "^4.1.2",
"express": "^4.17.1",
"gridfs-stream": "^1.1.1",
"is-empty": "^1.2.0",
"jsonwebtoken": "^8.5.1",
"mongoose": "^5.7.3",
"multer": "^1.4.2",
"multer-gridfs-storage": "^3.3.0",
"nodemon": "^1.19.3",
"passport": "^0.4.0",
"passport-jwt": "^4.0.0",
"validator": "^11.1.0"
},
"devDependencies": {
"nodemon": "^1.19.1"
}
}
and on the client side:
{
"name": "client",
"version": "0.1.0",
"private": true,
"dependencies": {
"axios": "^0.19.0",
"classnames": "^2.2.6",
"file-saver": "^2.0.2",
"jwt-decode": "^2.2.0",
"moment": "^2.24.0",
"react": "^16.10.1",
"react-app-polyfill": "^1.0.4",
"react-dom": "^16.10.1",
"react-redux": "^7.1.1",
"react-router-dom": "^5.1.2",
"react-scripts": "^3.2.0",
"redux": "^4.0.4",
"redux-thunk": "^2.3.0",
"sweetalert2": "^8.18.0",
"sweetalert2-react-content": "^1.1.0"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"proxy": "http://localhost:80",
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"react-social-icons": "^4.1.0"
}
}
I have tried running npm install on both the server and client side again, and have also deleted, the reinitialized the git repository. No luck. ANyone have any advice on how to get this build working?

Related

Laravel/NodeJS - npm ERR! Missing script: "watch"

I've upgraded to Laravel 9 recently.
Here is my package.json:
{
"private": true,
"scripts": {
"dev": "vite",
"build": "vite build"
},
"devDependencies": {
"#vitejs/plugin-vue": "^3.0.3",
"autoprefixer": "^10.4.8",
"axios": "^0.21",
"laravel-mix": "^6.0.6",
"laravel-vite-plugin": "^0.6.0",
"lodash": "^4.17.19",
"postcss": "^8.4.16",
"tailwindcss": "^3.1.8",
"vite": "^3.0.9"
},
"dependencies": {
"alpinejs": "^3.8.1",
"laravel-echo": "^1.11.3",
"pusher-js": "^7.0.3"
},
"name": "beastburst-website",
"description": "<p align=\"center\"><img src=\"https://raw.githubusercontent.com/laravel/art/master/logo-lockup/5%20SVG/2%20CMYK/1%20Full%20Color/laravel-logolockup-cmyk-red.svg\" width=\"400\"></p>",
"version": "1.0.0",
"main": "tailwind.config.js",
"directories": {
"test": "tests"
},
"repository": {
"type": "git",
"url": "https://code.scarsgaming.net/BeastBurst/BeastBurst-Website.git"
},
"keywords": [],
"author": "",
"license": "ISC"
}
When I run npm run watch I get the following error:
npm ERR! Missing script: "watch"
npm ERR!
npm ERR! To see a list of scripts, run:
npm ERR! npm run
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/venelin/.npm/_logs/2022-08-31T11_40_11_910Z-debug-0.log
Any idea why and how can I fix that?
The default bundler for Laravel now is Vite as you can clearly see from your package.json
If you do not want to use Vite, use this guide to switch to mix
I should also mention that Vite is much faster that mix.
try npm run dev it will work like npm run watch that is because Laravel 9 now uses Vite.

cannot start react app with the npm start command

I am trying to run my react-ebay-clone but the
npm start
command does not work. Instead react throws this error
freduah#freduah:~/react-ebay-clone/react-ebay-clone$ npm start
> react-ebay-clone#0.1.0 start /home/freduah/react-ebay-clone/react-ebay-clone
> react-scripts start
sh: 1: react-scripts: not found
npm ERR! code ELIFECYCLE
npm ERR! syscall spawn
npm ERR! file sh
npm ERR! errno ENOENT
npm ERR! react-ebay-clone#0.1.0 start: `react-scripts start`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the react-ebay-clone#0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/freduah/.npm/_logs/2020-10-26T19_24_02_415Z-debug.log
freduah#freduah:~/react-ebay-clone/react-ebay-clone$
Below Is My package.json file
{
"name": "react-ebay-clone",
"version": "0.1.0",
"private": true,
"dependencies": {
"#testing-library/jest-dom": "^5.11.5",
"#testing-library/react": "^11.1.0",
"#testing-library/user-event": "^12.1.10",
"react": "^17.0.1",
"react-dom": "^17.0.1",
"react-scripts": "4.0.0",
"web-vitals": "^0.2.4"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
I have found this previous stack overflow,
npm start error with create-react-app.

Errors on 'concurrently "npm run server" "npm run client" with MERN

First of all, I would like to apologize for the spelling mistakes, I'm not very good.
I have a problem whilethe starting my mern server...
I want to run it with with "npm run dev". This command line execute "npm run server" and "npm run client".
Here's my errors :
C:\Users\Jérémy\Desktop\Rendu\MERN\MERN_d04>npm run dev
mern_d04#1.0.0 dev C:\Users\Jérémy\Desktop\Rendu\MERN\MERN_d04
concurrently "npm run server" "npm run client"
[0] Error occurred when executing command: npm run server
[0] Error: spawn cmd.exe ENOENT
[0] at Process.ChildProcess._handle.onexit (internal/child_process.js:267:19)
[0] at onErrorNT (internal/child_process.js:467:16)
[0] at processTicksAndRejections (internal/process/task_queues.js:84:21)
[1] Error occurred when executing command: npm run client
[1] Error: spawn cmd.exe ENOENT
[1] at Process.ChildProcess._handle.onexit (internal/child_process.js:267:19)
[1] at onErrorNT (internal/child_process.js:467:16)
[1] at processTicksAndRejections (internal/process/task_queues.js:84:21)
[1] npm run client exited with code -4058
[0] npm run server exited with code -4058
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! mern_d04#1.0.0 dev: `concurrently "npm run server" "npm run client"`>npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the mern_d04#1.0.0 dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Jérémy\AppData\Roaming\npm-cache\_logs\2020-04-22T19_45_03_286Z-debug.log
And Here's, my root package.json :
{
"name": "mern_d04",
"version": "1.0.0",
"description": "",
"main": "server.js",
"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\""
},
"author": "",
"license": "ISC",
"dependencies": {
"bcryptjs": "^2.4.3",
"body-parser": "^1.19.0",
"concurrently": "^5.1.0",
"express": "^4.17.1",
"is-empty": "^1.2.0",
"jsonwebtoken": "^8.5.1",
"mongoose": "^5.9.10",
"passport": "^0.4.1",
"passport-jwt": "^4.0.0",
"validator": "^13.0.0"
},
"devDependencies": {
"nodemon": "^2.0.3"
}
}
And here's my client package.json :
{
"name": "client",
"version": "0.1.0",
"private": true,
"dependencies": {
"#testing-library/jest-dom": "^4.2.4",
"#testing-library/react": "^9.5.0",
"#testing-library/user-event": "^7.2.1",
"axios": "^0.19.2",
"classnames": "^2.2.6",
"jwt-decode": "^2.2.0",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"react-redux": "^7.2.0",
"react-router-dom": "^5.1.2",
"react-scripts": "3.4.1",
"redux": "^4.0.5",
"redux-thunk": "^2.3.0"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"proxy": "http://localhost:5000",
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
I've tried many things and, the most surprising thing is : it works on the computer of my friend but not mines.
Please someone can help me? :)
EDIT : Node version : 13.0.0
EDIT : Found the solution. I "just" had a variable "C:\Windows\System32" in the environment variables :)
I was facing the same problem.
for this code works, you can try this.. on your root package.json
"scripts": {
"start": "node index",
"server": "nodemon index",
"client": "npm run start --prefix client",
"dev": "concurrently \"npm run server\" \"cd client && npm start\""
},
and then from root directory type npm run dev
The node_modules are not compatible with your current systems. You may remove the node_modules folders at the root level AS WELL AS at the client level. Then you install both node_modules AGAIN.

ReferenceError: loader is not defined

I have been developing a React app with nodejs backend. Now I'm getting this error when I run npm run build. I have update node and npm to latest versions. I'm getting the following error log in the console.
$ npm run build
> client#0.1.0 build C:\Demos\mern-course\client
> react-scripts build
Creating an optimized production build...
Failed to compile.
./src/App.css
ReferenceError: loader is not defined
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! client#0.1.0 build: `react-scripts build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the client#0.1.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
My package.json is as follows.
{
"name": "client",
"version": "0.1.0",
"private": true,
"dependencies": {
"#testing-library/jest-dom": "^4.2.4",
"#testing-library/react": "^9.4.0",
"#testing-library/user-event": "^7.2.1",
"axios": "^0.19.2",
"bootstrap": "^4.4.1",
"react": "^16.12.0",
"react-dom": "^16.12.0",
"react-redux": "^7.2.0",
"react-scripts": "^3.4.0",
"react-transition-group": "^4.3.0",
"reactstrap": "^8.4.1",
"redux": "^4.0.5",
"redux-thunk": "^2.3.0",
"uuid": "^3.4.0"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"proxy": "http://localhost:5000",
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
Here is the link for github repo for the code.
./src/App.css
ReferenceError: loader is not defined
You need to check that you are importing App.css correctly. This should be in your App.js
Replace "css-loader" folder in front end node-modules folder with another "css-loader" which has taken from working react project.

Heroku with React and nodemailer build failing

Im having issues getting my build on heroku to work. Heroku is saying the build succeeded but when I pull up the page I get the Application Error page.
Here is my package.JSON for the React
{
"name": "cloudveilheli",
"version": "0.1.0",
"private": true,
"proxy": "http://localhost:3001",
"dependencies": {
"axios": "^0.18.0",
"body-parser": "^1.18.3",
"concurrently": "^3.5.1",
"express": "^4.16.3",
"firebase": "^4.8.1",
"moment": "^2.22.1",
"nodemailer": "^4.6.5",
"nodemon": "^1.17.5",
"re-base": "^3.2.1",
"react": "^16.2.0",
"react-dom": "^16.2.0",
"react-router": "^4.2.0",
"react-router-dom": "^4.2.2"
},
"devDependencies": {
"node-sass": "^4.7.2",
"react-scripts": "1.0.17",
"redux": "^3.7.2",
"sass-loader": "^6.0.6",
"webpack": "^3.10.0"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
}
}
and for the node.js
{
"name": "cloudveilheli",
"version": "0.1.0",
"private": true,
"proxy": "http://localhost:3001",
"dependencies": {
"axios": "^0.18.0",
"body-parser": "^1.18.3",
"concurrently": "^3.5.1",
"express": "^4.16.3",
"firebase": "^4.8.1",
"moment": "^2.22.1",
"nodemailer": "^4.6.5",
"nodemon": "^1.17.5",
"re-base": "^3.2.1",
"react": "^16.2.0",
"react-dom": "^16.2.0",
"react-router": "^4.2.0",
"react-router-dom": "^4.2.2"
},
"devDependencies": {
"node-sass": "^4.7.2",
"react-scripts": "1.0.17",
"redux": "^3.7.2",
"sass-loader": "^6.0.6",
"webpack": "^3.10.0"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
}
}
In the logs, I am getting an error that react-scripts are failing in the Heroku build process. The node and the react are getting fired but it fails soon after that.
And here are the heroku logs
2018-06-13T12:56:17.879178+00:00 app[web.1]: [1] sh: 1: react-scripts: not found
2018-06-13T12:56:17.910185+00:00 app[web.1]: [1] npm ERR! file sh
2018-06-13T12:56:17.910189+00:00 app[web.1]: [1] npm ERR! code ELIFECYCLE
2018-06-13T12:56:17.912160+00:00 app[web.1]: [1] npm ERR! errno ENOENT
2018-06-13T12:56:17.913985+00:00 app[web.1]: [1] npm ERR! syscall spawn
2018-06-13T12:56:17.922554+00:00 app[web.1]: [1] npm ERR! cloudveilheli#0.1.0 start: `react-scripts start`
2018-06-13T12:56:17.927487+00:00 app[web.1]: [1] npm ERR! spawn ENOENT
2018-06-13T12:56:17.928818+00:00 app[web.1]: [1] npm ERR!
2018-06-13T12:56:17.932398+00:00 app[web.1]: [1] npm ERR! Failed at the cloudveilheli#0.1.0 start script.
2018-06-13T12:56:17.932401+00:00 app[web.1]: [1] npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2018-06-13T12:56:17.967183+00:00 app[web.1]: [1] npm WARN Local package.json exists, but node_modules missing, did you mean to install?
2018-06-13T12:56:17.968219+00:00 app[web.1]: [1]
2018-06-13T12:56:17.968222+00:00 app[web.1]: [1] npm ERR! A complete log of this run can be found in:
2018-06-13T12:56:17.968224+00:00 app[web.1]: [1] npm ERR! /app/.npm/_logs/2018-06-13T12_56_17_935Z-debug.log
2018-06-13T12:56:17.992492+00:00 app[web.1]: [1] npm ERR! code ELIFECYCLE
2018-06-13T12:56:17.992495+00:00 app[web.1]: [1] npm ERR! errno 1
2018-06-13T12:56:17.996672+00:00 app[web.1]: [1] npm ERR! bluebirdheliapp#1.0.0 client: `npm run start --prefix cloudveil_heli_app`
2018-06-13T12:56:17.999397+00:00 app[web.1]: [1] npm ERR! Exit status 1
2018-06-13T12:56:18.004427+00:00 app[web.1]: [1] npm ERR!
2018-06-13T12:56:18.004430+00:00 app[web.1]: [1] npm ERR! Failed at the bluebirdheliapp#1.0.0 client script.
2018-06-13T12:56:18.004432+00:00 app[web.1]: [1] npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2018-06-13T12:56:18.021046+00:00 app[web.1]: [1]
2018-06-13T12:56:18.021050+00:00 app[web.1]: [1] npm ERR! A complete log of this run can be found in:
2018-06-13T12:56:18.021052+00:00 app[web.1]: [1] npm ERR! /app/.npm/_logs/2018-06-13T12_56_18_005Z-debug.log
2018-06-13T12:56:18.046560+00:00 app[web.1]: [1] npm run client exited with code 1
while you push your app to heroku
first it runs npm install
later it runs npm start
so we have to declare in package.json what to run after npm install is completed and what npm start need to do.
update you package.json with:
{
"name": "cloudveilheli",
"version": "0.1.0",
"private": true,
"proxy": "http://localhost:3001",
"scripts": {
"start": "node server.js",
"postinstall": "npm start build "
},
"dependencies": {
"axios": "^0.18.0",
"body-parser": "^1.18.3",
where postinstall works after the npminstall is completed
and create a server.js file like this:
const express = require('express');
const app = express();
app.use(express.static(__dirname + '/dist'));
app.all('*', (req, res) => {
res.status(200).sendFile(__dirname + '/dist/index.html');
});
app.listen(process.env.PORT || 8080);
at dist/index.html give where index.html created in react
as i dont know react

Resources