To fix webpack command not working with JavaScript, we add the webpack command to a script.
For instance, we write
{
"scripts": {
"build": "webpack --config webpack.config.js"
}
}
in package.json to add the build script.
We set it to run the webpack command with the webpack.config.js config.