React JS run-script build fails to compile - node.js

Problem description
>> npm run-script build fails to compile
Expected behavior
Successful compile, build folder contains a minified project, no errors in output
Actual behavior
Output gives out the following error:
react-scripts build
Creating an optimized production build...
Failed to compile.
Failed to minify the bundle. Error: static/js/main.e3925110.chunk.js from Terser
Name expected [static/js/main.e3925110.chunk.js:186,5]
at compiler.run (C:\Users\Zackyy\Desktop\ReactCoding\wanawiipuri\node_modules\react-scripts\scripts\build.js:176:23)
at finalCallback (C:\Users\Zackyy\Desktop\ReactCoding\wanawiipuri\node_modules\webpack\lib\Compiler.js:257:39)
at hooks.done.callAsync.err (C:\Users\Zackyy\Desktop\ReactCoding\wanawiipuri\node_modules\webpack\lib\Compiler.js:273:13)
at AsyncSeriesHook.eval [as callAsync] (eval at create (C:\Users\Zackyy\Desktop\ReactCoding\wanawiipuri\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:6:1)
at AsyncSeriesHook.lazyCompileHook (C:\Users\Zackyy\Desktop\ReactCoding\wanawiipuri\node_modules\tapable\lib\Hook.js:154:20)
at onCompiled (C:\Users\Zackyy\Desktop\ReactCoding\wanawiipuri\node_modules\webpack\lib\Compiler.js:271:21)
at hooks.afterCompile.callAsync.err (C:\Users\Zackyy\Desktop\ReactCoding\wanawiipuri\node_modules\webpack\lib\Compiler.js:671:15)
at AsyncSeriesHook.eval [as callAsync] (eval at create (C:\Users\Zackyy\Desktop\ReactCoding\wanawiipuri\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:6:1)
at AsyncSeriesHook.lazyCompileHook (C:\Users\Zackyy\Desktop\ReactCoding\wanawiipuri\node_modules\tapable\lib\Hook.js:154:20)
at compilation.seal.err (C:\Users\Zackyy\Desktop\ReactCoding\wanawiipuri\node_modules\webpack\lib\Compiler.js:668:31)
at AsyncSeriesHook.eval [as callAsync] (eval at create (C:\Users\Zackyy\Desktop\ReactCoding\wanawiipuri\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:6:1)
at AsyncSeriesHook.lazyCompileHook (C:\Users\Zackyy\Desktop\ReactCoding\wanawiipuri\node_modules\tapable\lib\Hook.js:154:20)
at hooks.optimizeAssets.callAsync.err (C:\Users\Zackyy\Desktop\ReactCoding\wanawiipuri\node_modules\webpack\lib\Compilation.js:1385:35)
at AsyncSeriesHook.lazyCompileHook (C:\Users\Zackyy\Desktop\ReactCoding\wanawiipuri\node_modules\tapable\lib\Hook.js:154:20)
at hooks.optimizeChunkAssets.callAsync.err (C:\Users\Zackyy\Desktop\ReactCoding\wanawiipuri\node_modules\webpack\lib\Compilation.js:1376:32)
Read more here: *removed*
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! wanawiipuri#0.1.0 build: `react-scripts build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the wanawiipuri#0.1.0 build 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\Zackyy\AppData\Roaming\npm-cache\_logs\2019-09-20T15_06_48_248Z-debug.log
Possible fixes that also failed
Stackoverflow community had a few solutions to this. First one being npm i react-scripts --save-dev, which did not make a difference.
Second being npm i terser#3.14.1 --save, also no progress.
Package.json
{
"name": "wanawiipuri",
"version": "0.1.0",
"private": true,
"dependencies": {
"firebase": "^6.6.1",
"firebase-admin": "^8.6.0",
"firebase-redux": "0.0.5",
"firebase-tools": "^7.3.2",
"react": "^16.9.0",
"react-dom": "^16.9.0",
"react-redux": "^7.1.1",
"react-redux-firebase": "^2.4.1",
"react-router-dom": "^5.0.1",
"redux": "^4.0.4",
"redux-firestore": "^0.9.0",
"redux-thunk": "^2.3.0",
"universal-cookie": "^4.0.2"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"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-scripts": "^3.1.2",
"terser": "^3.14.1"
}
}
Additional info
Project created using npx create-react-app. /
Windows 10 1903, /
VSCode /
ReactJS library /
Firebase hosting/firestore initialized /
I'm using npm, and I've got no idea if yarn-based possible fixes can do anything. Even though I tried, nothing worked so far.
**EDIT:
Also tried completely removing terser and installing both Terser#3.14.1 and then removing it and installing Terser#3.16.1 to test if any of the version work. No difference between versions.
Also tried installing terser as a dependency, both 3.14.1 and 3.16.1. Nothing works.
The build is not possible only with this project. Older projects are built successfully. Currently trying to find out what might have caused it.

I do not know HOW nor WHY, but the following solution worked for me.
I have this index.js file with code connecting firebase with my react. There was this line:
import { env } from './.env';
that is later used in
ReactDOM.render(<Provider store={store}><App env={env} /></Provider>, document.getElementById('root'));
So what I did is just commented out the import line and the env={env} part. NO IDEA why it worked, nor if I'll need it in the future, but this solved the problem for me.

This should be resolved in terser v3.16.1 - try to update your terser devDependency, as you are at v3.14.1.

In my case trying to require and old code gives the error:
from Terser Name expected
looking at code there was an:
var example, let;
let is a reserved name in ES6 like const etc... Be careful importing old code :)

Related

issues with running npm start on wsl2

I'm transitioning from working on an ubuntu remote server that I accessed through ssh, to my local windows machine and wsl2
I don't know JS at all, but what worked on the server suddenly is not working on my computer at all. I've tried all different kinds of npm commands found here, but to no avail
This is the full error I'm getting
nick#GameCube:~/Winions.gg/frontend/my-app$ npm start
> my-app#0.1.0 start /home/nick/Winions.gg/frontend/my-app
> react-scripts start
/home/nick/Winions.gg/frontend/my-app/node_modules/eslint-webpack-plugin/node_modules/jest-worker/build/index.js:110
_ending;
^
SyntaxError: Unexpected token ;
at Module._compile (internal/modules/cjs/loader.js:723:23)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Module.require (internal/modules/cjs/loader.js:692:17)
at require (internal/modules/cjs/helpers.js:25:18)
at Object.<anonymous> (/home/nick/Winions.gg/frontend/my-app/node_modules/eslint-webpack-plugin/dist/getESLint.js:9:5)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! my-app#0.1.0 start: `react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the my-app#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/nick/.npm/_logs/2022-12-11T03_44_57_094Z-debug.log
This is my package.json
{
"name": "my-app",
"version": "0.1.0",
"private": true,
"homepage": "https://winions.gg",
"dependencies": {
"#testing-library/jest-dom": "^5.16.5",
"#testing-library/react": "^13.4.0",
"#testing-library/user-event": "^13.5.0",
"axios": "^1.2.0",
"react": "^18.2.0",
"react-bootstrap": "^2.6.0",
"react-circular-progressbar": "^2.1.0",
"react-dom": "^18.2.0",
"react-icons": "^4.6.0",
"react-router-dom": "^6.4.3",
"react-scripts": "^5.0.1",
"web-vitals": "^2.1.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"
]
},
"devDependencies": {
"babel-eslint": "^10.1.0"
}
}
I just want to be able to run the react app. God help me please
Copying from my comment so this shows up as answered in the feed:
Older versions of Node don't support public fields on classes. 12.4 is the first Node version to support that syntax, and Jest is transpiled from TypeScript to support Node 14 as of this date. This table is a good resource for finding out what newer features of EcmaScript are supported in which versions of Node.

Heroku fail to compile: [eslint] Must use import to load ES Module

I'm trying to deploy a react app I worked on and when I try to push to heroku master it says "failed to compile node.js". Now I've already tried to specify what node I'm using and update to the lastest parser link, but still getting an error.
Here is what I'm getting in the terminal:
-----> Build
Running heroku-postbuild
> potato-network#1.0.0 heroku-postbuild /tmp/build_82788311
> cd client && npm install && npm run build
> core-js#3.25.4 postinstall /tmp/build_82788311/client/node_modules/core-js
> node -e "try{require('./postinstall')}catch(e){}"
> core-js-pure#3.25.4 postinstall /tmp/build_82788311/client/node_modules/core-js-pure
> node -e "try{require('./postinstall')}catch(e){}"
added 1429 packages from 795 contributors and audited 1434 packages in 21.79s
211 packages are looking for funding
run `npm fund` for details
found 1 high severity vulnerability
run `npm audit fix` to fix them, or `npm audit` for details
> client#0.1.0 build /tmp/build_82788311/client
> react-scripts build
Creating an optimized production build...
Failed to compile.
[eslint] Must use import to load ES Module: /tmp/build_82788311/client/node_modules/#eslint/eslintrc/universal.js
require() of ES modules is not supported.
require() of /tmp/build_82788311/client/node_modules/#eslint/eslintrc/universal.js from /tmp/build_82788311/client/node_modules/eslint/lib/linter/linter.js is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules.
Instead rename universal.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from /tmp/build_82788311/client/node_modules/#eslint/eslintrc/package.json.
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.
npm ERR! A complete log of this run can be found in:
npm ERR! /tmp/npmcache.h5MIg/_logs/2022-10-03T00_22_02_904Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! potato-network#1.0.0 heroku-postbuild: `cd client && npm install && npm run build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the potato-network#1.0.0 heroku-postbuild 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! /tmp/npmcache.h5MIg/_logs/2022-10-03T00_22_02_911Z-debug.log
-----> Build failed
Here is my package.json file:
{
"name": "client",
"proxy": "http://localhost:5000",
"version": "0.1.0",
"private": true,
"dependencies": {
"#testing-library/jest-dom": "^5.11.9",
"#testing-library/react": "^11.2.3",
"#testing-library/user-event": "^12.6.2",
"axios": "^0.21.1",
"express": "^4.18.1",
"moment": "^2.29.1",
"peerjs": "^1.3.2",
"react": "^17.0.1",
"react-dom": "^17.0.1",
"react-redux": "^7.2.2",
"react-router-dom": "^5.2.0",
"react-scripts": "^5.0.1",
"react-share": "^4.3.1",
"redux": "^4.0.5",
"redux-devtools-extension": "^2.13.8",
"redux-thunk": "^2.3.0",
"socket.io-client": "^3.1.2",
"web-vitals": "^0.2.4"
},
"devDependencies": {
"#babel/eslint-parser": "^7.5.4",
"babel-eslint": "^10.0.2",
"eslint": "^8.24.0",
"eslint-plugin-react": "^7.31.8"
},
"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"
]
}
}
Here is my .eslinct.js:
env: {
browser: true,
es2021: true,
},
parser: "#babel/eslint-parser",
extends: ["eslint:recommended", "plugin:react/recommended"],
overrides: [],
parserOptions: {
ecmaVersion: "latest",
requireConfigFile: false,
sourceType: "module",
},
plugins: ["react"],
rules: {},
How can I fix it? Googling the error does not present any useful forums or raised bugs.

Cannot read property 'createSnapshot' of undefined

Since I used Electron forge webpack plugin, when I execute npm start, it will cause an error after step Compiling Preload Scripts. It says the error is inside Forge.
I check it out, it's an error in file watcher api, that mainCompilation.fileSystemInfo is undefined, so it cannot read prop createSnapShot function.
What should I do to resolve this error and start my app?
Logs:
> datapack-planet#0.0.0 start D:\program\datapack-planet
> electron-forge start
√ Checking your system
√ Locating Application
You have set packagerConfig.ignore, the Electron Forge webpack plugin normally sets this automatically.
Your packaged app may be larger than expected if you dont ignore everything other than the '.webpack' folder
√ Preparing native dependencies
√ Compiling Main Process Code
√ Launch Dev Servers
√ Compiling Preload Scripts
An unhandled rejection has occurred inside Forge:
TypeError: Cannot read property 'createSnapshot' of undefined
at D:\program\datapack-planet\node_modules\html-webpack-plugin\lib\webpack5\file-watcher-api.js:13:36
at new Promise (<anonymous>)
at Object.createSnapshot (D:\program\datapack-planet\node_modules\html-webpack-plugin\lib\webpack5\file-watcher-api.js:12:10)
at D:\program\datapack-planet\node_modules\html-webpack-plugin\lib\cached-child-compiler.js:219:35
at processTicksAndRejections (internal/process/task_queues.js:93:5)
Electron Forge was terminated. Location:
{}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! datapack-planet#0.0.0 start: `electron-forge start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the datapack-planet#0.0.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! C:\Users\dell\AppData\Roaming\npm-cache\_logs\2021-01-22T04_33_47_591Z-debug.log
My package.json (NOT ALL, ONLY IMPORTANT DATA):
{
"main": "./.webpack/main",
"devDependencies": {
"#electron-forge/cli": "^6.0.0-beta.54",
"#electron-forge/maker-deb": "^6.0.0-beta.54",
"#electron-forge/maker-rpm": "^6.0.0-beta.54",
"#electron-forge/maker-squirrel": "^6.0.0-beta.54",
"#electron-forge/maker-zip": "^6.0.0-beta.54",
"#electron-forge/plugin-webpack": "^6.0.0-beta.54",
"#marshallofsound/webpack-asset-relocator-loader": "^0.5.0",
"#types/jquery": "^3.5.5",
"#types/node": "^14.14.22",
"electron": "^11.1.1",
"fork-ts-checker-webpack-plugin": "^6.1.0",
"html-loader": "^1.3.2",
"jquery": "^3.5.1",
"less": "^4.1.0",
"less-loader": "^7.2.1",
"node-loader": "^1.0.2",
"ts-loader": "^8.0.14",
"typescript": "^4.1.3",
"webpack": "^5.16.0",
"webpack-cli": "^4.4.0"
},
"dependencies": {
"electron-squirrel-startup": "^1.0.0",
"jquery": "^3.5.1"
},
"scripts": {
"start": "electron-forge start",
"package": "electron-forge package",
"make": "electron-forge make"
},
"config": {
"forge": {
"packagerConfig": {
"ignore": [
"\\.(idea|git)",
"config\\.json",
"[A-Z]",
"md$"
]
},
"makers": [
// There is some auto-generated settings, I didn't changed it.
// So I skip those configs.
],
"plugins": [
[
"#electron-forge/plugin-webpack",
{
"mainConfig": "./webpack.main.config.js",
"renderer": {
"config": "./webpack.renderer.config.js",
"entryPoints": [
{
"html": "./src/index.html",
"js": "./src/renderer.ts",
"name": "main_window"
}
]
}
}
]
]
}
}
}
Resolve: I restart the project. Maybe I missed some dependencies. I am copying from the template, so the bug may should be occurred as expected.
My work around was to remove node_modules and package-lock.json, and then run
npm install --legacy-peer-deps
There is an issue with very modern versions of npm and this gives you the legacy install rules which seem to work
I had the same issue which was resolved after checking and correcting the installed versions.
Run npm ls webpack to show the peer dependencies missing. This will help you figure out the right version required in your app.
Change to required version, save the package.json file.
Delete both package-lock.json and the node_modules folder.
Run npm install.
Run the script again.
I had this same issue and it seemed to be a compatibility issue with npm7 and plugin-webpack.
There are a few solutions, but the easiest for me was to simply use yarn instead of npm.
delete node_modules/
delete package-lock.json
run yarn install
run yarn start
This worked for me, let me know if this helps!
its due to mismatch of your webpack versions, just check npm list webpack, you will be able to see something like unmet dependecies.Just create peerDependencies and add webpack into it or can remove webpack inteself.Check your ts-loader version too,it should be less than 9.see the magic :)
run npm install or yarn inside the project, to install project's dependencies

I am getting error while using "npm start command for React application

I am new to react and this is my first application.
I have installed latest versions of node, npm/npx.
I created a directory using "create-react-app my-app".
After this when i enter the directory and type "npm start", I get the following error. Please help
C:\Users\admin\my-app>npm start
> my-app#0.1.0 start C:\Users\admin\my-app
> react-scripts start
Starting the development server...
events.js:288
throw er; // Unhandled 'error' event
^
Error: spawn cmd ENOENT
←[90m at Process.ChildProcess._handle.onexit (internal/child_process.js:267:19)←[39m
←[90m at onErrorNT (internal/child_process.js:469:16)←[39m
←[90m at processTicksAndRejections (internal/process/task_queues.js:84:21)←[39m
Emitted 'error' event on ChildProcess instance at:
←[90m at Process.ChildProcess._handle.onexit (internal/child_process.js:273:12)←[39m
←[90m at onErrorNT (internal/child_process.js:469:16)←[39m
←[90m at processTicksAndRejections (internal/process/task_queues.js:84:21)←[39m {
errno: ←[32m'ENOENT'←[39m,
code: ←[32m'ENOENT'←[39m,
syscall: ←[32m'spawn cmd'←[39m,
path: ←[32m'cmd'←[39m,
spawnargs: [ ←[32m'/s'←[39m, ←[32m'/c'←[39m, ←[32m'start'←[39m, ←[32m'""'←[39m, ←[32m'/b'←[39m, ←[32m'"http://localhost:3000"'←[39m ]
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! my-app#0.1.0 start: `react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the my-app#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! C:\Users\admin\AppData\Roaming\npm-cache\_logs\2020-04-12T15_19_48_491Z-debug.log
Here is my package.json content
{
"name": "my-app",
"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",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"react-scripts": "3.4.1"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"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"
]
}
}
As suggested by some, I have deleted my node modules folder and then did npm update followed by npm install but still i am getting the same error. Any help would be very much appreciated
I have seen this before. Try deleting your node_modules folder and after that run npm update and then npm install.
If that doesn't work there are a few answers from another forums:
Some windows users said that add System32 to environment variables helped:
Goto Control Panel > System and Security > System > Advanced system settings > Enviroment variables and set a system variable to path C:\Windows\System32\ and restart your System.
Worst case scenario: downgrade react-scripts to 2.1.8 :
npm install react-scripts#2.1.8

Unable to deploy application on heroku

I am receiving the following error while deploying my application on heroku, I have deployed it before with no problems. I also have not changed the package.json file, so I am unsure why I am getting the following error.
There are no additional configs for heroku, the application was previously deployed, and cannot be updated.
The application is deployed currently under a previous version through the heroku website from my github.
Any help to resolve this issue would be greatly appreciated!
error from heroku
-----> Build
Running heroku-postbuild
> operations-reporting#1.0.0 heroku-postbuild /tmp/build_04594e22478b41fb98f830b9b12c2400
> NPM_CONFIG_PRODUCTION=false npm install --prefix client && npm run build --prefix client
added 86 packages from 287 contributors and audited 906755 packages in 16.658s
found 2 moderate severity vulnerabilities
run `npm audit fix` to fix them, or `npm audit` for details
> client#0.1.0 build /tmp/build_04594e22478b41fb98f830b9b12c2400/client
> react-scripts build
internal/modules/cjs/loader.js:800
throw err;
^
Error: Cannot find module 'es-abstract/2019/CreateDataProperty'
Require stack:
- /tmp/build_04594e22478b41fb98f830b9b12c2400/client/node_modules/object.getownpropertydescriptors/implementation.js
- /tmp/build_04594e22478b41fb98f830b9b12c2400/client/node_modules/object.getownpropertydescriptors/index.js
- /tmp/build_04594e22478b41fb98f830b9b12c2400/client/node_modules/util.promisify/implementation.js
- /tmp/build_04594e22478b41fb98f830b9b12c2400/client/node_modules/util.promisify/index.js
- /tmp/build_04594e22478b41fb98f830b9b12c2400/client/node_modules/html-webpack-plugin/index.js
- /tmp/build_04594e22478b41fb98f830b9b12c2400/client/node_modules/react-scripts/config/webpack.config.js
- /tmp/build_04594e22478b41fb98f830b9b12c2400/client/node_modules/react-scripts/scripts/build.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:797:15)
at Function.Module._load (internal/modules/cjs/loader.js:690:27)
at Module.require (internal/modules/cjs/loader.js:852:19)
at require (internal/modules/cjs/helpers.js:74:18)
at Object.<anonymous> (/tmp/build_04594e22478b41fb98f830b9b12c2400/client/node_modules/object.getownpropertydescriptors/implementation.js:3:26)
at Module._compile (internal/modules/cjs/loader.js:959:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:995:10)
at Module.load (internal/modules/cjs/loader.js:815:32)
at Function.Module._load (internal/modules/cjs/loader.js:727:14)
at Module.require (internal/modules/cjs/loader.js:852:19) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'/tmp/build_04594e22478b41fb98f830b9b12c2400/client/node_modules/object.getownpropertydescriptors/implementation.js',
'/tmp/build_04594e22478b41fb98f830b9b12c2400/client/node_modules/object.getownpropertydescriptors/index.js',
'/tmp/build_04594e22478b41fb98f830b9b12c2400/client/node_modules/util.promisify/implementation.js',
'/tmp/build_04594e22478b41fb98f830b9b12c2400/client/node_modules/util.promisify/index.js',
'/tmp/build_04594e22478b41fb98f830b9b12c2400/client/node_modules/html-webpack-plugin/index.js',
'/tmp/build_04594e22478b41fb98f830b9b12c2400/client/node_modules/react-scripts/config/webpack.config.js',
'/tmp/build_04594e22478b41fb98f830b9b12c2400/client/node_modules/react-scripts/scripts/build.js'
]
}
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.
npm ERR! A complete log of this run can be found in:
npm ERR! /tmp/npmcache.PQkmQ/_logs/2019-12-14T21_42_39_533Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! operations-reporting#1.0.0 heroku-postbuild: `NPM_CONFIG_PRODUCTION=false npm install --prefix client && npm run build --prefix client`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the operations-reporting#1.0.0 heroku-postbuild 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! /tmp/npmcache.PQkmQ/_logs/2019-12-14T21_42_39_547Z-debug.log
-----> Build failed
We're sorry this build is failing! You can troubleshoot common issues here:
https://devcenter.heroku.com/articles/troubleshooting-node-deploys
Some possible problems:
- node_modules checked into source control
https://blog.heroku.com/node-habits-2016#9-only-git-the-important-bits
- Node version not specified in package.json
https://devcenter.heroku.com/articles/nodejs-support#specifying-a-node-js-version
Love,
Heroku
! Push rejected, failed to compile Node.js app.
! Push failed
package.json
{
"name": "client",
"version": "0.1.0",
"main": "index.js",
"private": true,
"dependencies": {
"axios": "^0.19.0",
"config": "^3.2.4",
"express": "^4.17.1",
"express-validator": "^6.3.0",
"formik": "^2.0.6",
"mongoose": "^5.7.12",
"react": "^16.12.0",
"react-dom": "^16.12.0",
"react-router-dom": "^5.1.2",
"react-scripts": "3.2.0",
"react-table": "^6.10.3",
"reactstrap": "^8.1.1",
"schema-utils": "^2.6.1"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"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": {
"concurrently": "^5.0.0",
"nodemon": "^2.0.1"
},
"proxy": "http://localhost:5000"
}
Find the missing module and update your package like so:
npm install --save --save-exact foo#1.2.3
This is from heroku
Other solution:
heroku config:set NODE_MODULES_CACHE=false

Resources