I'm receiving the error Uncaught Error: Cannot find module './App' at webpackMissingModule in the console of the local environment when I run npm start from the client directory.
The screen renders 2 errors.
ERROR in ./src/index.tsx 7:0-24 Module not found: Error: Can't resolve './App.tsx' in '/client/src'
ERROR in ./src/index.tsx 7:0-24 Module not found: Error: Can't resolve './store.ts' in '/client/src'
However, when I import the client directory of my project into a CodeSandbox, it is working.
Note, I did NOT create a webpack.config.js file in the client directory and tsconfig.json file in the root directory.
Instead, I'm using config-overrides.js as an alternative to webpack.config.js as I did not want to eject from the Create React App environment to setup my Webpack configuration.
Here are the contents of config-overrides.js.
const { override, addWebpackModuleRule } = require('customize-cra');
module.exports = override(
addWebpackModuleRule({
test: /\.(ts|tsx|js|jsx)$/,
loader: require.resolve('ts-loader'),
}),
addWebpackModuleRule({
test: /\.json$/,
loader: require.resolve('json-loader'),
type: 'javascript/auto',
})
);
Solution Attempts:
delete node_modules and package-lock.json, then npm install
npm cache clean --force and npm cache clear --force
assured the dependencies and packages installed in my local environment are the same in CodeSandbox.
assured file paths are correct
using Chrome on both local and CodeSandbox
Here is the CodeSandbox. What's going on?
Related
I have a completely clean install of create-react-app but when I try to use absolute paths it won't resolve the paths.
Everything seems correct since VSCode resolves the path successfully but the react app won't.
My tsconfig.file is also clean from npx create-react-app my-app --template typescript only extending to another tsconfig.path.json with the following:
{
"compilerOptions": {
"baseUrl": ".",
"paths": {
"#/*": ["./src/*"]
}
}
}
Error:
Compiled with problems:X
ERROR in ./src/App.tsx 7:0-44
Module not found: Error: Can't resolve '#/features/Comp' in 'C:\Users\REDACTED\PROJECT_ROOT\src'
I've tried to created another project with CRA just to test and the same occurs.
Also using simply the baseURL:["src"] wont resolve in the App but VSCode Successfuly resolves.
I found on web this tutorial. I set react application according to tutorial and all is OK. But now i would like add css file and divide application on components how is in this tutorial . I would like show default page after run command npm start . But when I added css file and App.jsx and wrote: npm start I got error:
ERROR in ./src/App.js
Module not found: Error: Can't resolve './App.css' in '/Users/username/Documents/Projects/myApp/frontend/src'
# ./src/App.js 21:0-19
# ./src/index.js
# multi (webpack)-dev-server/client?http://localhost:3000 (webpack)/hot/dev-server.js ./src/index.js
Thank you for your advice on how to set up your app to work properly.
Did you change the default folder structure you get when you use create-react-app. It looks like you have the location of the css file wrong.
The solution is:
npm install style-loader
npm install css-loader
and edit webpack.config.js how is in the link.
When I'm magrate webpack from v1 to v3, I meet the ERROR:
ERROR in ./index.js
Module build failed: (SystemJS) ENOENT: no such file or directory, open '/Users/zhangcong/Desktop/g/mi-insight-web/object-assign'
Error: ENOENT: no such file or directory, open '/Users/zhangcong/Desktop/g/mi-insight-web/object-assign'
Error loading /Users/zhangcong/Desktop/g/mi-insight-web/object-assign as "object-assign" from /Users/zhangcong/Desktop/g/mi-insight-web/node_modules/babel-loader/lib/index.js
This is the migrate guide I followed: see
I'm trying to rename modulesDirectories as modules, but failed.
Something I've done:
-root: PATH.SOURCE_PATH,
-modulesDirectories: ['node_modules'],
-extensions: ['', '.js', '.jsx'],
+modules: ['node_modules'],
+extensions: ['.js', '.jsx'],
and I migrate the postcss and removed the OccurenceOrderPlugin.
I've tried using path.resolve(), and I can't figure out why modules failed.
I solved by:
npm install postcss-import#8.0.2 --save-dev
see: babel-loader#242
I want to import this npm package from npm but it returns error
I have init new project and done this
npm install #google/maps --save
var googleMapsClient = require('#google/maps')
Error is this
this is error log
error: bundling: UnableToResolveError: Unable to resolve module `url` from `/Users/barron9/Downloads/meteor/node_modules/#google/maps/lib/internal/make-api-call.js`: Module does not exist in the module map or in these directories:
/Users/barron9/Downloads/meteor/node_modules
, /Users/barron9/Downloads/node_modules
This might be related to https://github.com/facebook/react-native/issues/4968
To resolve try the following:
1. Clear watchman watches: `watchman watch-del-all`.
2. Delete the `node_modules` folder: `rm -rf node_modules && npm install`.
3. Reset packager cache: `rm -fr $TMPDIR/react-*` or `npm start -- --reset-cache`.
at ResolutionRequest._resolveNodeDependency (/Users/barron9/Downloads/meteor/node_modules/react-native/packager/src/node-haste/DependencyGraph/ResolutionRequest.js:394:11)
at ResolutionRequest.resolveDependency (/Users/barron9/Downloads/meteor/node_modules/react-native/packager/src/node-haste/DependencyGraph/ResolutionRequest.js:141:29)
at dependencyNames.map.name (/Users/barron9/Downloads/meteor/node_modules/react-native/packager/src/node-haste/DependencyGraph/ResolutionRequest.js:145:59)
at Array.map (native)
at ResolutionRequest.resolveModuleDependencies (/Users/barron9/Downloads/meteor/node_modules/react-native/packager/src/node-haste/DependencyGraph/ResolutionRequest.js:145:42)
at Promise.resolve.then (/Users/barron9/Downloads/meteor/node_modules/react-native/packager/src/node-haste/DependencyGraph/ResolutionRequest.js:169:21)
at process._tickCallback (internal/process/next_tick.js:109:7)
Bundling `index.android.js` 94.3% (405/417), failed.
error: bundling: UnableToResolveError: Unable to resolve module `url` from `/Users/barron9/Downloads/meteor/node_modules/#google/maps/lib/internal/make-api-call.js`: Module does not exist in the module map or in these directories:
/Users/barron9/Downloads/meteor/node_modules
, /Users/barron9/Downloads/node_modules
Please try:
import googleMapsClient from '#google/maps';
Otherwise, that package does not target React-Native, I think.
Would you consider using the correct package for react-native, which works well in my react-native project:
https://github.com/airbnb/react-native-maps
I am using npm version 3 (version relevant because of the new way peerDependencies behave in version 3).
I have a reactjs app called "game" and a reactjs component called "player".
I am using webpack-dev-server to run "game" app.
react and react-dom are dependencies of game app and peerDependencies of the player component.
I would like to link player component to game app.
I have done:
cd /player
npm link
cd /game
npm link player
When I run webpack-dev-server program, I get the following error message:
Hash: 09968e7401389f50049f
Version: webpack 1.12.2
Time: 339ms
chunk {0} app.js, 0.14192ce06d8b6f8abb91.hot-update.js, app.css (app) 2.32 MB
+ 576 hidden modules
ERROR in ../player/index.js
Module not found: Error: Cannot resolve module 'react' in /player
# ../player/index.js 21:13-29
How do I make player component to use game ./node_modules for the peerDependences?
After a bit of digging, I have found a solution in the webpack documentation: npm linked modules doesn’t find their dependencies.
Simply add resolve.fallback (and resolveLoader.fallback if your dependencies have loader specific logic, such as using CSS Modules) to your webpack config:
resolve: {
fallback: path.resolve(__dirname, './node_modules')
},
resolveLoader: {
fallback: path.resolve(__dirname, './node_modules')
}
The fallback setting will make webpack loader look into the local ./node_modules path for any dependencies that cannot be resolved, including the dependencies of the dependencies of the main app itself. As a result, all peerDependencies of the main app dependencies will be resolved against the main app ./node_modules.