javascriptnode.jswebpackcss-loaderwebpack-style-loader

error style-loader@3.2.1: The engine "node" is incompatible with this module. Expected version ">= 12.13.0". Got "10.19.0"


I'm trying to install css-loader and style-loader in webpack but It shows this error. It seems like my node version is old that's why I tried to upgrade my node version using nvm (Node Version Manager) But I couldn't install nvm in my Linux machine and I ended up uninstalling the nodejs from my system and reinstalled it but still It shows me the following versions.

Nodejs: v10.19.0 Npm: v7.20.5

I'm using Linux ( Ubuntu ) LTS

Can someone please tell me what's the main issue It's not letting me install loaders in webpack? I'm almost new to webpack and I've attached my webpack configuration file below.

webpack.config.js

module.exports = {
  module: {
    rules: [
      {
        test: /\.(js|jsx)$/,
        exclude: /node_modules/,
        use: { loader: 'babel-loader' },
      },
      {
        test: /\.css$/,
        use: ['style-loader', 'css-loader'],
      },
    ],
  },
};

Solution

  • I like to install new packages using distribuition managers. Using this link https://github.com/nodesource/distributions/blob/master/README.md#debinstall, identify what's your linux and its commands to update/install a newer nodejs version.

    In my case, Ubuntu with the sequence:

        node -v
        10.19.0 // my old version
        # Using Ubuntu
        curl -fsSL https://deb.nodesource.com/setup_16.x | sudo -E bash -
        sudo apt-get install -y nodejs
        node -v
        v16.9.1 // my newest version