1
I’m trying to create my first Reactjs application.
When running on the bash terminal of Vscode the following command:
yarn webpack-dev-server --mode development
The following error appears:
$ yarn webpack-dev-server --mode development
yarn run v1.22.10
$ C:\tools\Cmder\react\node_modules\.bin\webpack-dev-server --mode development
node:internal/modules/cjs/loader:928
throw err;
^
Error: Cannot find module 'webpack-cli/bin/config-yargs'
Require stack:
- C:\tools\Cmder\react\node_modules\webpack-dev-server\bin\webpack-dev-server.js
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:925:15)
at Function.Module._load (node:internal/modules/cjs/loader:769:27)
at Module.require (node:internal/modules/cjs/loader:997:19) at require (node:internal/modules/cjs/helpers:92:18)
at Object.<anonymous> (C:\tools\Cmder\react\node_modules\webpack-dev-server\bin\webpack-dev-server.js:65:1)
at Module._compile (node:internal/modules/cjs/loader:1108:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1137:10)
at Module.load (node:internal/modules/cjs/loader:973:32)
at Function.Module._load (node:internal/modules/cjs/loader:813:14)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:76:12) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'C:\\tools\\Cmder\\react\\node_modules\\webpack-dev-server\\bin\\webpack-dev-server.js'
]
}
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
I’ve tried to put all scripts on package.json
that I saw in stackoverflow and already installed the yarn
in various ways.
My webpack.config.js looks like this:
const path = require('path');
module.exports = {
entry: path.resolve(__dirname, 'src', 'index.js'),
output: {
path: path.resolve(__dirname, 'public'),
filename: 'bundle.js'
},
devServer: {
contentBase: path.resolve(__dirname, 'public'),
},
module: {
rules:[
{
test: /\.js$/,
exclude: /node_modules/,
use: {
loader:'babel-loader',
}
}
]
}
};
Which version of webpack-cli you are using?
– Cmte Cardeal
$ webpack-cli --version webpack 5.22.0 webpack-cli 4.5.0 webpack-dev-server 3.11.2
– Kellymary de Araujo