Reputation: 690
I've created react app with create-react-app and I'm unable to add alias to resolve -> alias node in webpack.config.js located in node_modules/react-scripts/config: Module not found: Can't resolve '@/_components' in 'c:\my-app\src\app'
alias: {
'@': path.resolve(__dirname, 'src/'),
Probably missing smth simple... Here are webpack docs: https://webpack.js.org/configuration/resolve/#resolvealias
Upvotes: 1
Views: 929
Reputation: 10382
once you use create-react-app
the standard way to modify your webpack setting is to run npm run eject
as stated docs and not modify directly at node_modules as you are trying to.
to avoid the ejecting command you could use a helper lib react-app-rewired which simplifies the process for overriding some default webpack configurations.
nevertheless, create-react-app
offers the option to point absolute paths through a jsconfig.json file like stated in the docs reference which might suit you better:
{
"compilerOptions": {
"baseUrl": "src"
},
"include": ["src"]
}
Upvotes: 2