I am working on a React webapp using webpack, loosely alongside this tutorial.
Accidentally, I added the node_modules folder to my git. I then removed it again using
FYI, to access any script via command-line like you were trying, you need to have the script registered as a shell-script (or any kind of script like .js, .rb) in the system like these files in the the dir
/usr/binin UNIX. And, system must know where to find them. i.e. the location must be loaded in$PATHarray.
In your case, the script webpack-dev-server is already installed somewhere inside ./node_modules directory, but system does not know how to access it. So, to access the command webpack-dev-server, you need to install the script in global scope as well.
$ npm install webpack-dev-server -g
Here, -g refers to global scope.
However, this is not recommended way because you might face version conflicting issues; so, instead you can set a command in npm's package.json file like:
"scripts": {
"start": "webpack-dev-server -d --config webpack.dev.config.js --content-base public/ --progress --colors"
}
This setting will let you access the script you want with simple command
$ npm start
So short to memorize and play. And, npm knows the location of the module webpack-dev-server.