question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

this.getOptions is not a function when try to launch NextJS app

See original GitHub issue
  • Operating System: OSX 11.3 beta
  • Node Version: 12.19.0
  • NPM Version: 6.14.8
  • webpack Version: 4.41.2
  • source-map-loader Version: 2.0.1

Expected Behavior

When I run my NextJS app, should bundle and link the sources map and finally run the app successfully.

Actual Behavior

NextJS app is not launched successfully with runtime errors when try to run source-map-loader:

error - ../node_modules/next/node_modules/@next/react-refresh-utils/runtime.js
TypeError: this.getOptions is not a function

Code

This is the current implementation for next.config.js

module.exports = {
  webpack: (config, options) => {
    // Note: we provide webpack above so you should not `require` it
    // Perform customizations to webpack config
    // Load source maps in dev mode
    if (config.mode === "development") {
      config.module.rules.push({
        test: /\.js$/,
        use: ["source-map-loader"],
        enforce: "pre",
      });
    }

    config.plugins.push(new options.webpack.IgnorePlugin(/\/__tests__\//));

    // Important: return the modified config
    return config;
  },
};

How Do We Reproduce?

Yo need to create a boilerplate app with NextJS and install source-map-loader and create a next.config.js by simply running the follow commands:

npx create-next-app nextjs-example --use-npm --example "https://github.com/vercel/next-learn-starter/tree/master/learn-starter"

and install the dependency:

npm i -D source-map-loader

and create a next.config.js at the root the project and copy the code above and run:

npm run dev

and you’ll be able to reproduce this error. It looks like source-map-loader is not able to access webpack context or whatever the getOptions method is located.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
alexander-akaitcommented, Mar 9, 2021

You need webpack v5 to use latest version of sourcer-map-loader

0reactions
arielnmz-iwscommented, Feb 23, 2022

How can I make CRACO use webpack 5?

Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeError: this.getOptions is not a function - vue.js
A quick fix is to remove that additional package from XXXX/node_modules . You can also check what package version the XXXX module use...
Read more >
Module build failed: TypeError: this.getOptions is not a function
Sage10.– Finds out this is sage 9 When I do 'yarn start', I get this issue: error in ./resources/assets/styles/main.scss Module build failed: TypeError: ......
Read more >
'this.getOptions is not a function' when trying to use html-loader
Whenever I run npm run serve I get 'Syntax Error: TypeError: this.getOptions is not a function', pointing to my game's index.html.
Read more >
IsConnected not a function in next.js app - MongoDB
I'm starting to use the mongodb driver for next.js. I followed the example of How to Integrate MongoDB Into Your Next.js App but...
Read more >
Type Error: this.getOptions is not a function For style-loader ...
Downgraded style-loader 1 major version to 2.0.0 : npm i style-loader@2.0.0 · Then, as luck would have it, I ran into the same...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found