(I'm attempting to follow this tutorial)
When I run npm start I get the following error:
PS C:\Users\user\Desktop\Projects\Websites\project\project> npm start
> [email protected] start C:\Users\user\Desktop\Projects\Websites\project\project
> webpack-dev-server --config webpack.config.js --open
'find_dp0' is not recognized as an internal or external command,
operable program or batch file.
internal/modules/cjs/loader.js:775
throw err;
^
Error: Cannot find module 'C:\webpack-dev-server\bin\webpack-dev-server.js'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:772:15)
at Function.Module._load (internal/modules/cjs/loader.js:677:27)
at Function.Module.runMain (internal/modules/cjs/loader.js:999:10)
at internal/main/run_main_module.js:17:11 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
I think the main issue is that it's looking for the webpack-dev-server module in my C:/ drive since the error is saying:
Error: Cannot find module 'C:\webpack-dev-server\bin\webpack-dev-server.js'
Why would it be looking there for the module and not in the local node_modules folder? This is at least what I think is causing the issue, maybe it is something else though?
I couldn't find this same error online anywhere else (where it was looking in the users C:/ drive). I am working in Visual Studio Community 2019. Any help would be greatly appreciated!
package.json:
{
"name": "drewpel.com",
"description": "drewpel.com",
"author": "James Pelusi",
"version": "0.0.0",
"private": true,
"scripts": {
"start": "webpack-dev-server --config webpack.config.js --open",
"test": "echo \"Error: no test script was specified\" && exit 1"
},
"dependencies": {
"express": "4.17.1",
"morgan": "1.10.0",
"pug": "3.0.0"
},
"devDependencies": {
"css-loader": "4.2.2",
"extract-loader": "5.1.0",
"file-loader": "6.0.0",
"sass": "1.26.10",
"sass-loader": "10.0.1",
"webpack": "4.44.1",
"webpack-cli": "3.3.12",
"webpack-dev-server": "3.11.0"
}
}
webpack.config.js:
module.exports = [{
entry: './css/index.scss',
output: {
// This is necessary for webpack to compile
// But we never use style-bundle.js
filename: 'style-bundle.js',
},
module: {
rules: [
{
test: /\.scss$/,
use: [
{
loader: 'file-loader',
options: {
name: 'bundle.css',
},
},
{ loader: 'extract-loader' },
{ loader: 'css-loader' },
{
loader: 'sass-loader',
options: {
// Prefer Dart Sass
implementation: require('sass'),
// See https://github.com/webpack-contrib/sass-loader/issues/804
webpackImporter: false,
},
},
]
}
]
},
}];
"start": "webpack serve --config webpack.config.js --open"
change the package.json start to this above . I hope it will work
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With