#npm run dev not working

32 messages · Page 1 of 1 (latest)

loud elbow
#

My nodejs version is on 18.12.1

#

and my npm version on 9.1.2

quick owl
#

by the error message it looks like there is something wrong in the config file in line 5

loud elbow
#
/** @type {import('next').NextConfig} */
const nextConfig = {
  reactStrictMode: true,
  swcMinify: true,
};
config.plugins.push(
  new webpack.ProgressPlugin((percentage, message, ...args) => {
    // e.g. Output each progress message directly to the console:
    console.info(percentage, message, ...args);
  })
);
module.exports = nextConfig;
module.exports = {
  pageExtensions: ["mdx", "md", "jsx", "js", "tsx", "ts"],
};
#

This is my nextconfig file

#

What could be wrong about this?

quick owl
#

where is config coming from?

loud elbow
#

To my knowledge I left it the way it was when creating the next js app

quick owl
#

you can't have two module.exports at the same time too, they are overriding each other

loud elbow
#

So I should merge them?

quick owl
#

if thats all the file have then config is undefined

#

hence the error

loud elbow
#

Mmh how would I go around that? I never had this error before as my dev environment had always worked with next

#

because how should i define config?

loud elbow
#

I searched like 50 links on google but the only thing I read are people saying the node version is not up to date

#

However I checked and they are so it must be something else

#

To my knowledge I never touched the config file, with the only exception for the pageExtensions

quick owl
#

the next config allows you to extend the default webpack config which is probably what this code is doing

#

so to fix the code you would move it inside the webpack property of the first config object you created

#
const nextConfig = {
  reactStrictMode: true,
  swcMinify: true,
  webpack: (config) => {
    config.plugins.push(...) // your code here
  }
}```
#

then for the other issue (the double module.exports), you can move the pageExtensions inside this object as well

loud elbow
#

Thanks a lot I removed it for now but I am going to try this tomorrow!

quick owl
#

tbh I don't think you even need this line (config.plugins), it is adding a progress plugin which will just output a lot of stuff in the terminal

loud elbow
#
    new webpack.ProgressPlugin((percentage, message, ...args) => {
      // e.g. Output each progress message directly to the console:
      console.info(percentage, message, ...args);
    })
  }
};```
#

So I still need the config within it?

quick owl
#

you need the config.plugins.push part otherwise that would instancialize the plugin in the void

#

I mean you don't need this plugin at all

loud elbow
#

So I can just delete the webpack all together?

quick owl
#

yep