Linux, node_modules, webpack issue
by hljhende from LinuxQuestions.org on (#6M0KP)
Hey guys, newbie linux user here.
I'm having issues with node_modules and npm.
Our project is built in React & Node, and it works fine on other people's Windows machines - but not on my local linux.
Basically, I have a package.json which contains a list of all the required dependencies and devDependencies for a project.
When you run "npm install" this installs all said dependencies into node_modules.
However, when I try and build the project with 'webpack --mode production' I get an error saying webpack was not installed. It is definitely there in devDependencies...but it's not (usually) in node_modules. It's like the computer doesn't know where to look. It's also completely indeterministic, and node_modules sometimes has webpack and sometimes doesn't.
Similarly, with the webpack configuration, webpack.config.js
Webpack is supposed to load HtmlWebpackPlugin, like so:
const HtmlWebpackPlugin = require('html-webpack-plugin').
But it can't find it! html-webpack-plugin is clearly defined in package.json, although it doesn't seem to be in node_modules..
I've tried quite a few things, including uninstalling and reinstalling nvm, node and npm - to no avail.
What does fix the error is if I move all the devDependencies to dependencies in package.json - but that's obviously not ideal for development.
I'm wondering if this has something to do with how linux finds files, but it's completely baffling me. Any help would be greatly appreciated.
Thanks!
I'm having issues with node_modules and npm.
Our project is built in React & Node, and it works fine on other people's Windows machines - but not on my local linux.
Basically, I have a package.json which contains a list of all the required dependencies and devDependencies for a project.
When you run "npm install" this installs all said dependencies into node_modules.
However, when I try and build the project with 'webpack --mode production' I get an error saying webpack was not installed. It is definitely there in devDependencies...but it's not (usually) in node_modules. It's like the computer doesn't know where to look. It's also completely indeterministic, and node_modules sometimes has webpack and sometimes doesn't.
Similarly, with the webpack configuration, webpack.config.js
Webpack is supposed to load HtmlWebpackPlugin, like so:
const HtmlWebpackPlugin = require('html-webpack-plugin').
But it can't find it! html-webpack-plugin is clearly defined in package.json, although it doesn't seem to be in node_modules..
I've tried quite a few things, including uninstalling and reinstalling nvm, node and npm - to no avail.
What does fix the error is if I move all the devDependencies to dependencies in package.json - but that's obviously not ideal for development.
I'm wondering if this has something to do with how linux finds files, but it's completely baffling me. Any help would be greatly appreciated.
Thanks!