score:103
Try run script below:
npm install style-loader --save
Modify webpack config, add modulesDirectories
field in resolve
.
resolve: {
extensions: ['', '.js', '.jsx', '.css'],
modulesDirectories: [
'node_modules'
]
}
score:-1
it is very simple you have to install the fist syle-loader the css-loader.
score:1
If you're node_modules are on the same dir as your webpack config file you can simply add context: __dirname
.
module.exports = {
context: __dirname,
entry: [
...
(works in both webpack 1 and 2)
score:2
I use Windows and did everything but nothing worked. It appeared console didn't have enough permissions. So, after running in Admin mode I re-entered
npm install
and everything worked. You can see the result by appearing a lot of modules in node_modules directory.
score:11
Under Webpack 3, with node_module
in a non-standard location, I had to use both resolve
and resolveLoader
configuration objects:
resolve: {
modules: ["build-resource/js/node_modules"]
},
resolveLoader: {
modules: ["build-resource/js/node_modules"]
},
score:13
I wanted to add on to what David Guan said. In the newer versions of Webpack (V2+) moduleDirectories
has been replaced with modules
. The updated resolve
portion of his answer would look like this:
resolve: {
extensions: ['.js', '.jsx', '.css'], //An empty string is no longer required.
modules: [
'node_modules'
]
}
For more information you can check out their official documentation. Hope this helps someone out there.
score:18
If you try to import a css file with this line:
import '../css/style.css';
and have added the style-loader
in your webpack config.
The error states:
Module not found: Error: Cannot resolve module 'style-loader'
the module named "style-loader" is not resolved.
You need to install that module with:
$ npm install style-loader --save
Or, if you're using yarn:
$ yarn add style-loader
Then run webpack
again.
score:32
Please run this script:
npm install style-loader css-loader --save
Set your module as below:
module: {
loaders: [
{
test: /\.jsx?$/,
loader: 'babel-loader',
include: path.join(_dirname, 'app')
},
{
test: /\.css$/,
loader: 'style-loader!css-loader'
}
],
resolve: {
extensions: ['', '.js', '.jsx', '.css']
}
}
It's basically reading as for loaders - test jsx using babel-loader and the next test is a css file using style-loader and css-loader, which will recognize the modules. Also, you should exit out of npm start, and run "npm install" and run "npm start". Hopefully, this should take care of the issue.
Source: stackoverflow.com
Related Query
- Error after update: Cannot resolve module 'react/lib/ReactMount'
- webpack config error of cannot resolve module
- webpack: ERROR in Entry module not found: Error: Cannot resolve 'file' or 'directory' .jsx
- Error: Cannot resolve module 'style-loader'
- ERROR in Cannot find module 'babel-core'. using react.js, webpack, and express server
- How to fix this error : " Module not found :can't resolve popper.js "
- Cannot resolve module 'react-dom'
- "module not found : Error: Cannot resolve module 'react/lib/ReactMount' "
- Bundle error using webpack for Electron application `Cannot resolve module 'electron'`
- React Native Error Cannot find module 'metro-config/src/defaults/blacklist'
- How to resolve ' error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature.'?
- Dealing with "Failed to load plugin 'react' declared in '.eslintrc': Cannot find module 'eslint-plugin-react'" ESLint error
- Module not found: Error: Cannot resolve module 'fs'
- Cannot find module '../request' error using mock in Jest
- React-native bundling failure. ERROR MESSAGE: "While trying to resolve module 'idb'..... Indeed none of these files exist":
- Webpack and TypeScript: Cannot resolve module 'child_process' in node.d.ts
- react-router cannot resolve module history, missing lib folder
- Module not found: Error: Cannot resolve module 'react-addons-test-utils'
- React: Flow: Import a local js file - cannot resolve issue module
- Cannot use JSX with nodejs ESM module loader
- How to solve, craco: *** Cannot find ESLint loader (eslint-loader). *** error with ANTd and React (2021)
- react native sudden Unable to resolve module `fs` error
- why do i get the Error Module not found: Can't resolve 'redux'
- Cannot resolve module "firebase" from 'firebase.js' : Firebase could not be found within the project
- Module not found: Error: Cannot resolve module 'react-redux'
- error TS2307: Cannot find module 'react'
- Cannot find module '../../images/Logo.png'.ts(2307) Red Error is Still showing
- Module not found: Error: Cannot resolve module 'react' when I use webpack
- Cannot resolve module while trying to organize modules in React Native
- ERROR in Entry module not found: Error: Can't resolve 'babel-loader'
More Query from same tag
- Getting error while updating state in reactjs
- Unable to get cytoscape undo-redo to work correctly
- How to add a new textfield on button click and add integer value of that input field to an array in react
- Why I can't access the properties json data by the property name in reactjs?
- JSX wrap div in <a> tag if url exists
- How can I delete cart item on index using Redux?
- General route interceptors for react-router
- Is it possible to use same function to setstate on different objects
- how to push an item into an array if it is inside a javascript object [state.lastValue.push is not a function]
- Children are undefined when using <Route /> from react-router
- React: Slider with useEffect hook not working properly when trying to save the slider's state into local storage
- Host Server Side Rendering using NodeJS on Heroku
- How can I reset a piece of Redux, but maintain the rest?
- How to not change the state at the first render of React component?
- How to toggle css class on React
- nextjs and bootstrap5 modal
- useEffect cleanup function? Memory leak error
- React js simple hook effect
- Using React IndexRoute in react-router v4
- scroll eventlistener is interupting the scrolling event it triggers
- How to load json dynamically in reactjs component?
- How to change the height of MUI Datepicker input box in React
- Receiving the message: Cannot GET / error while using NodeJS and React
- React Firebase - Fetching an item by id
- CypressError: Timed out retrying: cy.its() errored because the property: 'store' does not exist on your subject
- Non lambda in React-Router V4 render function
- How do i display data i have stored from a fetch request?
- How do I get these panels to show in a scrollable table format?
- Embedding bokeh chart in reactjs frontend
- update data only if state changes with react