Cannot read property 'createSnapshot' of undefined - node.js

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

Related

Heroku Shopify Application Error 'npm ERR! ERESOLVE unable to resolve dependency tree'

Greetings I have a problem with Heroku because it's don't want to install legacy packages for my Shopify app, my Shopify app is on Github and I just set up everything that my application needs, but when I deploy the main branch on Heroku I get this error in Heroku console below, can someone help me fix this?
-----> Building on the Heroku-20 stack
-----> Using buildpack: heroku/nodejs
-----> Node.js app detected
-----> Creating runtime environment
NPM_CONFIG_LOGLEVEL=error
USE_NPM_INSTALL=true
NODE_VERBOSE=false
NODE_ENV=production
NODE_MODULES_CACHE=false
-----> Installing binaries
engines.node (package.json): unspecified
engines.npm (package.json): unspecified (use default)
Resolving node version 16.x...
Downloading and installing node 16.14.0...
Using default npm version: 8.3.1
-----> Restoring cache
Caching has been disabled because NODE_MODULES_CACHE=false
-----> Installing dependencies
Installing node modules (package.json + package-lock)
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: shopify-app-node#1.0.0
npm ERR! Found: react#16.14.0
npm ERR! node_modules/react
npm ERR! react#"^16.10.1" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react#"^17.0.2 || ^18.0.0-0" from next#12.0.10
npm ERR! node_modules/next
npm ERR! next#"^12.0.2" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR! See /tmp/npmcache.CTfHl/eresolve-report.txt for a full report.
npm ERR! A complete log of this run can be found in:
npm ERR! /tmp/npmcache.CTfHl/_logs/2022-02-10T12_18_50_156Z-debug-0.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 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
My package.json
{
"name": "shopify-app-node",
"version": "1.0.0",
"description": "Shopify's node app for CLI tool",
"scripts": {
"test": "jest",
"dev": "cross-env NODE_ENV=development nodemon ./server/index.js --watch ./server/index.js",
"build": "NEXT_TELEMETRY_DISABLED=1 next build",
"start": "cross-env NODE_ENV=production node ./server/index.js"
},
"engines": {
"node": "16.14.0",
"npm": "8.4.1"
},
"repository": {
"type": "git",
"url": "git+https://github.com/Shopify/shopify-app-node.git"
},
"author": "Shopify Inc.",
"license": "MIT",
"bugs": {
"url": "https://github.com/shopify/shopify-app-node/issues"
},
"dependencies": {
"#babel/core": "7.12.10",
"#babel/polyfill": "^7.6.0",
"#babel/preset-env": "^7.12.11",
"#babel/register": "^7.12.10",
"#shopify/app-bridge-react": "^2.0.2",
"#shopify/app-bridge-utils": "^2.0.2",
"#shopify/koa-shopify-auth": "^4.1.2",
"#shopify/polaris": "^6.2.0",
"apollo-boost": "^0.4.9",
"axios": "^0.25.0",
"cross-env": "^7.0.3",
"dotenv": "^8.2.0",
"graphql": "^14.5.8",
"isomorphic-fetch": "^3.0.0",
"koa": "^2.13.1",
"koa-bodyparser": "^4.3.0",
"koa-compress": "^5.1.0",
"koa-cors": "0.0.16",
"koa-logger": "^3.2.1",
"koa-router": "^10.0.0",
"koa-session": "^6.1.0",
"mysql2": "^2.3.3",
"next": "^12.0.2",
"next-env": "^1.1.0",
"node-fetch": "^2.6.7",
"react": "^16.10.1",
"react-apollo": "^3.1.3",
"react-dom": "^16.10.1",
"sequelize": "^6.13.0",
"slugify": "^1.6.5",
"validator": "^13.7.0",
"webpack": "^4.44.1"
},
"devDependencies": {
"#babel/plugin-transform-runtime": "^7.12.10",
"#babel/preset-stage-3": "^7.0.0",
"babel-jest": "26.6.3",
"babel-register": "^6.26.0",
"enzyme": "3.11.0",
"enzyme-adapter-react-16": "1.15.6",
"husky": "^4.3.6",
"jest": "26.6.3",
"lint-staged": "^10.5.4",
"nodemon": "^2.0.7",
"prettier": "2.2.1",
"react-addons-test-utils": "15.6.2",
"react-test-renderer": "16.14.0"
},
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
},
"lint-staged": {
"*.{js,css,json,md}": [
"prettier --write"
]
}
}
If you cannot reproduce locally, set package.json engines: to match your local development
This is not the OP's exact issue as they had specified engines: and reproduced locally, so definitely what they needed was to resolve it locally first, which is a subset of the infinite Unable to resolve dependency tree error when installing npm packages
But I couldn't reproduce locally even after delting node_modules and package-lock.json, so as soon as I set engines:, which Heroku respects, to match my local working setup node --version and npm --version with:
"engines": {
"node": "14.17.0",
"npm": "6.14.13"
},
it started working on Heroku. Here's my failing package.json to which the engines were added. The error was:
remote: Installing node modules (package.json)
remote: npm ERR! code ERESOLVE
remote: npm ERR! ERESOLVE unable to resolve dependency tree
remote: npm ERR!
remote: npm ERR! While resolving: conduit-node#1.0.0
remote: npm ERR! Found: react#17.0.2
remote: npm ERR! node_modules/react
remote: npm ERR! react#"17.0.2" from the root project
remote: npm ERR!
remote: npm ERR! Could not resolve dependency:
remote: npm ERR! peer react#"^16.11.0" from swr#0.3.0
remote: npm ERR! node_modules/swr
remote: npm ERR! swr#"0.3.0" from the root project
Prior to the fix, Heroku logs show it was using:
remote: Downloading and installing node 16.14.0...
remote: Using default npm version: 8.3.1
For this reason, you should Always, Always, set engines to match your local setup on a Heroku project.
Ciro Santilli's way solved my problem:
I added these lines to package.json and the problem fixed:
"engines": {
"node": "16.x",
"npm": "8.5.5"
},
Apparently for me the "knex" module that I use is not compatible with newer npm (I am not sure).
You may use .npmrc
New versions of npm do not allow you to install dependencies with different versions of peer dependencies because it may lead to breaking change. So if you are sure that everything works without any issues, maybe you have good tests. Just add --legacy-peer-deps or --force after your npm script (basically it's npm i). But it's so annoying to write it, instead you can create '.npmrc' file in the root of your project with following:
legacy-peer-deps=true
...
or even:
force=true
...
Now you don't need to add --legacy-peer-deps or --force manually.
ps. It also solves the problem with Heroku when you cannot explicitly use npm i --legacy-peer-deps. At least I don't know how to do so.
I found a solution. You can add config variables in Heroku apps.
Go to the app in Heroku -> settings -> Reveal Config Vars
Add a new config var with the key: NPM_CONFIG_LEGACY_PEER_DEPS and value true, and then redeploy.
I install these old packages with npm install --force
I run npm outdated
I see what packages are in red
I do upgrade from the current version to the wanted version with npm install --save packagename#wanted_version
Remove any empty files that you may have in your project
Uploaded to git
Deploy to Heroku
Your lock file contains conflicting dependencies. Since you were able to reproduce the error locally using npm ci we have a good way to test a fix locally.
It looks like you are depending directly on React 16. Is that something that you need directly, or is it just a dependency for Next.js?
If it's not something you need directly, upgrade it per the Next.js docs:
npm install react#latest react-dom#latest
That should modify your package-lock.json. Then try installing from the lock file again with npm ci. If that fixes things, commit the change and redeploy.
On the other hand, if you are directly depending on React 16 and cannot upgrade you'll have to consider rolling back to an earlier version of Next.js.

How do I solve npm install issue after deleting node_modules

I am trying to clean out my react-native project's package to do a clean npm install on a MacOS based system (my windows system for Android development has no issues in cleaning up package versions).
I started seeing errors in the npm instals complaining version differences betwces are not compatible and list differences between versions of each package in "rook project" and node_modules/ directory.
I do the usual fix by removing package-lock.json, delete the node_modules directory and re-run npm install. from my project folder. It immediately made the same error complaints. The problem is this, there is no node_modules in my project folder as I deleted it. And it did not create a new node_modules directory.
Given this issue, how do I debug this and fix it? Questions I'd like to find out:
how do I tell npm to tell me what it thinks root project value is (full path)?
How to tell npm to tell me where the full path to the node_modules directory it seems to see?
Finally, how do I force npm to do the right thing and focus my my project's collaterals and not look outside the project folder as it appears to be doing?
Some of my thoughts. I don't understand why it is making a package cersion comparison between root project and node_modules?
Seems that nodde and npm are doing different things in MacOS environment than in my windows system environment -- I don't understand this.
Anyone here can help me understand what is going on and how to solve it?
The Error output here:
thomas#Presonus americanaradio % npm install
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: AmericanaRadio#0.0.2
npm ERR! Found: react#16.14.0
npm ERR! node_modules/react
npm ERR! react#"^16.13.1" from the root project
npm ERR! peer react#"^16.8" from
#react-native-community/async-storage#1.12.1
npm ERR! node_modules/#react-native-community/async-storage
npm ERR! #react-native-community/async-storage#"^1.12.1" from the
root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react#"17.0.2" from react-native#0.66.4
npm ERR! node_modules/react-native
npm ERR! react-native#"^0.66.3" from the root project
npm ERR! peer react-native#">=0.59" from
#react-native-community/async-storage#1.12.1
npm ERR! node_modules/#react-native-community/async-storage
npm ERR! #react-native-community/async-storage#"^1.12.1" from the
root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency
resolution.
npm ERR!
npm ERR! See /Users/thomas/.npm/eresolve-report.txt for a full report.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/thomas/.npm/_logs/2021-12-10T15_47_02_669Z-debug.log
thomas#Presonus americanaradio %
The package.json content here:
{END)
"name": "AmericanaRadio",
"version": "0.0.2",
"private": true,
"scripts": {
"android": "react-native run-android",
"ios": "react-native run-ios",
"start": "react-native start",
"test": "jest",
"lint": "eslint ."
},
"dependencies": {
"#react-native-community/async-storage": "^1.12.1",
"#react-native-community/checkbox": "^0.5.2",
"#react-native-community/masked-view": "^0.1.10",
"#react-native-community/slider": "^3.0.3",
"node-fetch": "^2.6.1",
"react": "^16.13.1",
"react-native": "^0.66.3",
"react-native-background-timer": "^2.4.1",
"react-native-elements": "^3.4.2",
"react-native-gesture-handler": "^1.9.0",
"react-native-keyboard-aware-scroll-view": "^0.9.5",
"react-native-reanimated": "^2.2.4",
"react-native-safe-area-context": "^3.1.9",
"react-native-screens": "^2.15.2",
"react-native-simple-survey": "^3.1.2",
"react-native-swift": "^1.2.1",
"react-native-vector-icons": "^8.0.0",
"react-native-version-check": "^3.4.2",
"react-native-version-info": "^1.1.0",
"react-native-webview": "^11.3.1",
"react-navigation": "^4.4.3",
"react-navigation-drawer": "^2.6.0",
"react-navigation-stack": "^2.10.2",
"react-usestateref": "^1.0.8",
"socket.io-client": "^4.4.0"
},
"devDependencies": {
"#babel/core": "^7.12.10",
"#babel/runtime": "^7.12.5",
"#react-native-community/eslint-config": "^2.0.0",
"babel-jest": "^26.6.3",
"eslint": "^7.18.0",
"jest": "^26.6.3",
"metro-react-native-babel-preset": "^0.64.0",
"react-test-renderer": "16.13.1"
},
"jest": {
"preset": "react-native"
}
}
~
(END)
As noted in my description, the node_modules directory was deleted and running npm install failed and did not create a nodes_modules directory. So the error messages are confusing as I have no packages in my project directory (americanaradio).
Thank you for taking a look at this and hopefully a solution can come out of ths.
First check what library is giving you an error and try to reinstall or update that version . Try deleting node modules also . Then do npm install.

ENOENT: no such file or directory when running npm install command

When I run npm install, I getting the following error,
npm WARN tar ENOENT: no such file or directory, open 'D:\Live Project\insyte-mobile\insyte-mobile\node_modules.staging\core-js-c9f4d03d\library\fn\symbol\unscopables.js'
Here is a screen shoot of the error
:
Here is my package.json
{
"name": "tonight-mobile",
"version": "0.1.0",
"private": true,
"devDependencies": {
"jest-expo": "~27.0.0",
"react-test-renderer": "16.3.1"
},
"main": "node_modules/expo/AppEntry.js",
"scripts": {
"start": "expo start",
"eject": "expo eject",
"initial-android": "npm install && npm run android",
"initial-ios": "npm install && npm run ios",
"android": "expo start --android",
"ios": "expo start --ios",
"test": "jest",
"postinstall": "rm ./node_modules/react-native/local-cli/core/__fixtures__/files/package.json"
},
"jest": {
"preset": "jest-expo"
},
"dependencies": {
"axios": "^0.18.0",
"expo": "^32.0.0",
"expo-image-picker": "^5.0.2",
"firebase": "^5.7.1",
"firebase-admin": "^8.5.0",
"firebase-functions": "^3.2.0",
"react": "16.5.0",
"react-native": "https://github.com/expo/react-native/archive/sdk-32.0.0.tar.gz",
"react-native-firebase": "^5.1.1",
"react-native-image-crop-picker": "^0.21.3",
"react-native-image-picker-form": "^0.2.5",
"react-native-maps": "^0.21.0",
"react-native-responsive-image": "^2.3.1",
"react-native-swiper": "^1.5.14",
"react-native-vector-icons": "^5.0.0",
"react-navigation": "^2.13.0",
"react-navigation-tabs": "^1.0.2",
"react-redux": "^5.0.7",
"redux": "^4.0.0",
"redux-persist": "^5.10.0",
"redux-persist-filesystem-storage": "^1.3.2",
"redux-thunk": "^2.3.0",
"tcomb-form-native": "^0.6.20"
}
}
above is the package.json file.
I have also used another code of this project, but this time I'm getting following error :
First delete the package-lock.json and then try npm install
Delete node_modules folder and package-lock.json, then run npm install
All you need to do is
Open a terminal in your pc's root and run this command:
killall node
Before restart the new metro bundler please reinstall the dependencies on yarn or npm :
npm i OR yarn
Also the article: ENOENT: no such file
Follow this step:
Delete node_modules folder and package-lock.json file
Run this command:
npm cache clean -force
Then run this command:
npm install (if the issue is not yet fixed try the following 4th step.)
Run this command npm install -g npm,then npm install
Finally run this command: npm start
Please check your current working directory. if you have created project using
npx react-native init demo
then navigate inside project from terminal using
cd demo
npm install
will install all npm modules and you can also check installed packages in the directory: demo/node_modules
also if project is expo base then
run expo eject to eject from expo
Check the node version, if the application was build using an older node version then you can downgrade your local environment node version using NVM (node version manager).
My simple solution for this error:
"npm WARN tar ENOENT:no such file or directory
Not only for ENOENT if all files in npm modules shows this kinds of error.
Go to your command prompt
Check for npm version(npm -v)
If its giving a version then type command npm init and click on enter for whatever it asks
After completing all the steps and then again try to create one angular project. It will be created without any errors in node modules.
npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path E:\Projects\package.json
npm ERR! errno -4058
npm ERR! enoent ENOENT: no such file or directory, open 'E:\Projects\package.json'
npm ERR! enoent This is related to npm not being able to find a file.
Solution ==> Check the root directory you might be outside the root directory or in wrong folder path has been opened
I suspect you do not have git installed on your computer. This is particularly true if you are getting this error at the bottom of your log:
npm ERR! syscall spawn git
If so, then you need to install git from here: https://git-scm.com/downloads.
I had the same problem as you, and once I installed git, the problem went away.
Do you have a package.json file in the folder ?*
To run npm install you need to have a package.json file.

React JS run-script build fails to compile

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 :)

npm gives error when installing module not specified by me

I am trying to install the modules needed by my application using
npm install
When I do this, I get the following error:
npm ERR! Error: No compatible version found: gulp-util#'^3.0.0'
npm ERR! Valid install targets:
npm ERR! ["0.0.1","1.0.0","1.1.0","1.1.1","1.2.0","1.3.0","2.0.0","2.1.1","2.1.2","2.1.3","2.1.4","2.2.0","2.2.1","2.2.2","2.2.3","2.2.5","2.2.6","2.2.7","2.2.8","2.2.9","2.
2.10","2.2.11","2.2.12","2.2.13","2.2.14","2.2.15","2.2.16","2.2.17","2.2.18","2.2.19","2.2.20","3.0.0","3.0.1","3.0.2","3.0.3","3.0.4","3.0.5","3.0.6"]
However, I never require this module into my project.
I'm assuming it's an issue internal of npm or node.
Furthermore, also strange is that when I run
npm list -g
I get the following output rather than seeing the versions of npm which are installed.
├── node#0.0.0
My package.json file is:
{
"name": "myProject",
"version": "0.0.1",
"dependencies": {},
"scripts": {
"test": "gulp test"
},
"devDependencies": {
"browserify": ">=9.0.7",
"gulp": ">=3.8.11",
"gulp-concat": ">=2.6.0",
"gulp-html-replace": ">=1.5.1",
"gulp-react": ">=3.0.1",
"gulp-streamify": ">=1.0.2",
"gulp-uglify": ">=1.2.0",
"gulp-util": ">=3.0.6",
"reactify": ">=1.1.1",
"vinyl-source-stream": ">=1.1.0"
},
"engines": {
"node": ">=0.10.0"
}
}
Your version of npm is so old that it doesn't support version ranges specified using ^. You are not using that syntax but it is quite likely one of the modules you are specifying is using that syntax for it's dependencies, and so when it tries to run npm install gulp-util#'^3.0.0' it throws that error.
If you update your npm either by updating node or by installing the latest npm with npm install -g npm then you should be able to proceed.

Resources