My project can't be compiled anymore. It came suddenly , I didn't get why.
It seems to be related to webpack. Maybe I need to downgrade webpack the version before 5 but I don't see how to do it in React.
I managed to reduce errors from 90 to 7 with adding resolve:fallback but I don't know what to do with others.
So, now I have these errors:
Failed to compile.
Module not found: Error: Can't resolve 'child_process' in '/Users/yulia/Documents/DEV/JS_REACT/projects/arrosy-moved/node_modules/jest-worker/build/workers'
WARNING in ./node_modules/jest-worker/build/WorkerPool.js 25:4-29
Module not found: Error: Can't resolve 'worker_threads' in '/Users/yulia/Documents/DEV/JS_REACT/projects/arrosy-moved/node_modules/jest-worker/build'
WARNING in ./node_modules/jest-worker/build/base/BaseWorkerPool.js 122:19-46
Critical dependency: the request of a dependency is an expression
WARNING in ./node_modules/jest-worker/build/index.js 71:19-38
Critical dependency: the request of a dependency is an expression
WARNING in ./node_modules/jest-worker/build/workers/processChild.js 83:15-28
Critical dependency: the request of a dependency is an expression
WARNING in ./node_modules/jest-worker/build/workers/processChild.js 99:15-28
Critical dependency: the request of a dependency is an expression
WARNING in ./node_modules/loader-runner/lib/loadLoader.js 20:19-39
Critical dependency: the request of a dependency is an expression
WARNING in ./node_modules/terser-webpack-plugin/dist/minify.js 43:118-125
Critical dependency: require function is used in a way in which dependencies cannot be statically extracted
WARNING in ./node_modules/terser-webpack-plugin/dist/utils.js 519:18-51
Module not found: Error: Can't resolve 'uglify-js/package.json' in '/Users/yulia/Documents/DEV/JS_REACT/projects/arrosy-moved/node_modules/terser-webpack-plugin/dist'
WARNING in ./node_modules/terser-webpack-plugin/dist/utils.js 596:18-51
Module not found: Error: Can't resolve '#swc/core/package.json' in '/Users/yulia/Documents/DEV/JS_REACT/projects/arrosy-moved/node_modules/terser-webpack-plugin/dist'
WARNING in ./node_modules/terser-webpack-plugin/dist/utils.js 678:18-49
Module not found: Error: Can't resolve 'esbuild/package.json' in '/Users/yulia/Documents/DEV/JS_REACT/projects/arrosy-moved/node_modules/terser-webpack-plugin/dist'
WARNING in ./node_modules/webpack/lib/EvalSourceMapDevToolPlugin.js
Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from '/Users/yulia/Documents/DEV/JS_REACT/projects/arrosy-moved/node_modules/webpack/lib/[url]' file: Error: ENOENT: no such file or directory, open '/Users/yulia/Documents/DEV/JS_REACT/projects/arrosy-moved/node_modules/webpack/lib/[url]'
WARNING in ./node_modules/webpack/lib/debug/ProfilingPlugin.js 29:14-34
Module not found: Error: Can't resolve 'inspector' in '/Users/yulia/Documents/DEV/JS_REACT/projects/arrosy-moved/node_modules/webpack/lib/debug'
WARNING in ./node_modules/webpack/lib/serialization/ObjectMiddleware.js 679:18-34
Critical dependency: the request of a dependency is an expression
ERROR in ./node_modules/jest-worker/build/workers/ChildProcessWorker.js 9:15-39
Module not found: Error: Can't resolve 'child_process' in '/Users/yulia/Documents/DEV/JS_REACT/projects/arrosy-moved/node_modules/jest-worker/build/workers'
ERROR in ./node_modules/jest-worker/build/workers/NodeThreadsWorker.js 29:15-40
Module not found: Error: Can't resolve 'worker_threads' in '/Users/yulia/Documents/DEV/JS_REACT/projects/arrosy-moved/node_modules/jest-worker/build/workers'
ERROR in ./node_modules/jest-worker/build/workers/messageParent.js 23:8-33
Module not found: Error: Can't resolve 'worker_threads' in '/Users/yulia/Documents/DEV/JS_REACT/projects/arrosy-moved/node_modules/jest-worker/build/workers'
ERROR in ./node_modules/terser-webpack-plugin/dist/utils.js 481:6-26
Module not found: Error: Can't resolve 'uglify-js' in '/Users/yulia/Documents/DEV/JS_REACT/projects/arrosy-moved/node_modules/terser-webpack-plugin/dist'
ERROR in ./node_modules/terser-webpack-plugin/dist/utils.js 560:14-34
Module not found: Error: Can't resolve '#swc/core' in '/Users/yulia/Documents/DEV/JS_REACT/projects/arrosy-moved/node_modules/terser-webpack-plugin/dist'
ERROR in ./node_modules/terser-webpack-plugin/dist/utils.js 639:18-36
Module not found: Error: Can't resolve 'esbuild' in '/Users/yulia/Documents/DEV/JS_REACT/projects/arrosy-moved/node_modules/terser-webpack-plugin/dist'
ERROR in ./node_modules/webpack/lib/FileSystemInfo.js 11:19-36
Module not found: Error: Can't resolve 'module' in '/Users/yulia/Documents/DEV/JS_REACT/projects/arrosy-moved/node_modules/webpack/lib'
Did you mean './module'?
Requests that should resolve in the current directory need to start with './'.
Requests that start with a name are treated as module requests and resolve within module directories (node_modules, /Users/yulia/Documents/DEV/JS_REACT/projects/arrosy-moved/node_modules).
If changing the source code is not an option there is also a resolve options called 'preferRelative' which tries to resolve these kind of requests in the current directory too.
webpack compiled with 7 errors and 13 warnings
I recently upgraded my react app - initially created with CRA, but i'm getting an error i can't figure out how to solve :
ERROR in ./node_modules/dotenv/lib/main.js 24:11-24
Module not found: Error: Can't resolve 'fs' in '/project/frontend-react/node_modules/dotenv/lib'
EDIT:
what am I doing to get this error : npm start
where do I get that error : in the browser, the app is not loading at all
and in regard to the error it's really all i'm getting
Any help welcome, as i'm lost despite quiet a lot of research...
Well, I was using dotenv on the app, removing it cleared the error...
My project failed to compile saying ./src/index.js
Module not found: Can't resolve './registerServiceWorker' in 'C:\Users\Jaybee\Desktop\Projects\webzone\src'
Can you show index.js file?
And also check out this thread, it may be the same problem:
Module not found: Can't resolve './registerServiceWorker
React noob here. Trying to clone and run https://github.com/strangebnb/react-airbnb
I clone. run npm install. Then webpack but I get
ERROR in ./~/react-tap-event-plugin/src/injectTapEventPlugin.js
Module not found: Error: Cannot resolve module 'react/lib/EventPluginHub' in /Users/thomas/tom/node_modules/react-tap-event-plugin/src
# ./~/react-tap-event-plugin/src/injectTapEventPlugin.js 23:2-37
ERROR in ./~/react-tap-event-plugin/src/TapEventPlugin.js
Module not found: Error: Cannot resolve module 'react/lib/EventConstants' in /Users/thomas/tom/node_modules/react-tap-event-plugin/src
# ./~/react-tap-event-plugin/src/TapEventPlugin.js 22:21-56
ERROR in ./~/react-tap-event-plugin/src/TapEventPlugin.js
Module not found: Error: Cannot resolve module 'react/lib/EventPluginUtils' in /Users/thomas/tom/node_modules/react-tap-event-plugin/src
# ./~/react-tap-event-plugin/src/TapEventPlugin.js 23:23-60
ERROR in ./~/react-tap-event-plugin/src/TapEventPlugin.js
Module not found: Error: Cannot resolve module 'react/lib/EventPropagators' in /Users/thomas/tom/node_modules/react-tap-event-plugin/src
# ./~/react-tap-event-plugin/src/TapEventPlugin.js 24:23-60
ERROR in ./~/react-tap-event-plugin/src/TapEventPlugin.js
Module not found: Error: Cannot resolve module 'react/lib/SyntheticUIEvent' in /Users/thomas/tom/node_modules/react-tap-event-plugin/src
# ./~/react-tap-event-plugin/src/TapEventPlugin.js 25:23-60
ERROR in ./~/react-tap-event-plugin/src/TapEventPlugin.js
Module not found: Error: Cannot resolve module 'react/lib/ViewportMetrics' in /Users/thomas/tom/node_modules/react-tap-event-plugin/src
# ./~/react-tap-event-plugin/src/TapEventPlugin.js 27:22-58
ERROR in ./~/react-portal/build/portal.js
Module not found: Error: Cannot resolve module 'react/lib/CSSPropertyOperations' in /Users/thomas/tom/node_modules/react-portal/build
# ./~/react-portal/build/portal.js 17:29-71
I found https://github.com/thereactivestack/meteor-webpack/issues/21 (I see this is very recent, read: yesterday), and after messing around with my packages.json, changing react, react-dom, material-ui version numbers and running npm i --save react-tap-event-plugin, I got down to 'only' 1 error message
ERROR in ./~/react-portal/build/portal.js
Module not found: Error: Cannot resolve module 'react/lib/CSSPropertyOperations' in /Users/thomas/react-airbnb/node_modules/react-portal/build
# ./~/react-portal/build/portal.js 17:29-71
I'm pretty new and I'm not sure how to go about fixing this. Any hints greatly welcomed.
Thanks
Due to update in React, react-tap-event-plugin breaks
Change react-tap-event-plugin to ^2.0.0 in your package.json if using react version ^15.4.0.
I forked that repo and fixed this issue in my repo. Also, sent pull request to the owner of original repo. Here's link to my forked repo:
https://github.com/pankajvishwani/react-airbnb
If you don't want to clone my repo, you can add the following in webpack.config.js:
var reactDomLibPath = path.join(__dirname, "./node_modules/react-dom/lib");
var alias = {};
["EventPluginHub", "EventConstants", "EventPluginUtils", "EventPropagators",
"SyntheticUIEvent", "CSSPropertyOperations", "ViewportMetrics"].forEach(function(filename){
alias["react/lib/"+filename] = path.join(__dirname, "./node_modules/react-dom/lib", filename);
});
module.exports = {
...
resolve: {alias: alias},
...
}
UPDATE: As of React 16 the react-tap-event-plugin is deprecated and no longer required https://www.npmjs.com/package/react-tap-event-plugin
Old solution redundant as of React 16
Updating the react tap event plugin to over 2.0.1 will fix your issue if you're using React 15.4.0.
A new React version has been released (https://github.com/facebook/react/blob/master/CHANGELOG.md), and I read recently that there have been big changes where react-dom still secretly lived on in the react package but is now being removed. If you read 15.4.0, the first point: 'React package and browser build no longer "secretly" includes React DOM. (#sebmarkbage in #7164 and #7168)'
Also reading the tap event plugins npm docs: Only the latest tap event plugin (v2.0.1 currently) supports React 15.4+. https://www.npmjs.com/package/react-tap-event-plugin
Check the version of React and react-tap-event-plugin.
npm list --depth=0
In the short term, you could fix React to a specific earlier version.
If your package.json file contains something like:
"react": "^15.3.2",
in the dependencies section, you could change it to say
"react": "=15.3.2”,
For react 16+ react-tap-event-plugin is not required anymore:
react-tap-event-plugin
I am using rewire prior to require method in my React/Flux app, to load components. But after installation I got this error:
ERROR in ./~/rewire/lib/rewire.js
Module not found: Error: Cannot resolve module 'module' in /Users/path/node_modules/rewire/lib
# ./~/rewire/lib/rewire.js 1:13-30
ERROR in ./~/rewire/lib/rewire.js
Module not found: Error: Cannot resolve module 'fs' in /Users/path/node_modules/rewire/lib
# ./~/rewire/lib/rewire.js 2:9-22
ERROR in ./~/rewire/lib/moduleEnv.js
Module not found: Error: Cannot resolve module 'module' in /Users/path/node_modules/rewire/lib
# ./~/rewire/lib/moduleEnv.js 3:13-30
ERROR in ./~/rewire/lib/moduleEnv.js
Module not found: Error: Cannot resolve module 'fs' in /Users/path/node_modules/rewire/lib
# ./~/rewire/lib/moduleEnv.js 4:9-22
While googling I found similar issue, but no desirable solution. Does anyone know what is the issue or conflict about and how to resolve it?
This is a webpack issue.
Since you're trying to use rewire, I'll assume you plan to run your tests through NodeJS and not a browser. Otherwise, check out rewire-webpack.
Rewire expects a NodeJS environment, but by default webpack targets a browser environment, and as such doesn't know about the standard NodeJS modules that rewire might depend on.
You need to set the target property of your webpack config to "node" in order to let webpack know it should consider standard NodeJS modules as externals.