Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[edge] Module build failed: TypeError: Cannot read property 'eslint' of undefined #3216

Closed
tdhulster opened this issue Apr 11, 2018 · 7 comments

Comments

Projects
5 participants
@tdhulster
Copy link

commented Apr 11, 2018

Version

edge

Reproduction link

https://github.com/tdhulster/nuxt-edge

Steps to reproduce

npm install -g vue-cli
vue init nuxt-community/starter-template nuxt-test
npm uninstall nuxt
npm install nuxt-edge -S
npm run dev

What is expected ?

No error is thrown

What is actually happening?

Following error is thrown:
Module build failed: TypeError: Cannot read property 'eslint' of undefined
at Object.module.exports (/node_modules/eslint-loader/index.js:148:18)

You may use special comments to disable some warnings.
Use // eslint-disable-next-line to ignore the next line.
Use /* eslint-disable */ to ignore all warnings in a file.

Additional comments?

All comments and steps can be found in Readme as well

This bug report is available on Nuxt.js community (#c6888)

@cmty cmty bot added the cmty:bug-report label Apr 11, 2018

@syffs

This comment has been minimized.

Copy link

commented Apr 12, 2018

@tdhulster isClient was removed in nuxt-edge, it should be replaced by process.client in your nuxt.config.js as below:

extend (config, { isDev }) {
  if (isDev && process.client) {
	config.module.rules.push({
	  enforce: 'pre',
	  test: /\.(js|vue)$/,
	  loader: 'eslint-loader',
	  exclude: /(node_modules)/
	})
  }
}
@tdhulster

This comment has been minimized.

Copy link
Author

commented Apr 12, 2018

AHA! Damn, so simple :) Thank you!

I didn't look into it since the blogpost stated that everything would be magically migrated.

💡 MIGRATION TIP: The good news is that you don’t need to change a single line of code in your project. Everything will be magically migrated as soon as you upgrade to Nuxt 2.

And therefore overlooked this one:

Remove deprecated features from Nuxt 1.0 : Removed context.isServer and context.isClient (Use process.client and process.server)

Issue can be closed I guess but might be usefull for other people having the same issue.

@tdhulster tdhulster closed this Apr 12, 2018

@Atinux Atinux added this to Done in Bugs 🐞 Aug 8, 2018

@amoshydra

This comment has been minimized.

Copy link
Contributor

commented Aug 10, 2018

@tdhulster @syffs
For some reason, process.client return undefined on my end. I was able to configure eslint correctly using ctx.isClient instead.

I believe the correct configuration should be using ctx.isClient instead of process.client inside the build extend function.

  build: {
    /*
    ** Run ESLint on save
    */
    extend (config, { isDev, isClient }) {
      if (isDev && isClient) {
        config.module.rules.push({
          enforce: 'pre',
          test: /\.(js|vue)$/,
          loader: 'eslint-loader',
          exclude: /(node_modules)/
        })
      }
    }

See the nuxt.config in the updated starter-template nuxt-community/starter-template@a2d4038

Related clarification regarding to this confusion: #3145

Also, I believe that the reason process.server, process.client, process.browser being undefined at this stage is due to both client.js or server.js not being executed yet at the moment.

@cmty

This comment has been minimized.

Copy link

commented Aug 22, 2018

This bug-report has been fixed by @syffs.

See comment

@cmty cmty bot added the cmty:status:fixed label Aug 22, 2018

@Legym

This comment has been minimized.

Copy link

commented Aug 22, 2018

I was able to find a workaround: webpack/webpack#6556 (comment)

build: {
    extend(config, { isDev, isClient }) {
      // Run ESLint on save
      if (isDev && isClient) {
        config.module.rules.push({
          enforce: 'pre',
          test: /\.(js|vue)$/,
          loader: 'eslint-loader',
          exclude: /(node_modules)/,
          options: {
            fix: true
          }
        })
      }
    },
    plugins: [
      new webpack.LoaderOptionsPlugin({ options: {} })
    ]
  },

I couldn't get the build to lint if I use process.client. However reverting back to the old legacy isClient was able to work. I am having the same issues as @amoshydra where process.client was undefined

Update: I updated the npm packageeslint-loader to the latest and it's fixed.

@XanderLuciano

This comment has been minimized.

Copy link

commented Oct 23, 2018

@syffs Your comment would inadvertently disable linting (and thus just disable any linting errors) because process.client is undefined at this point. The correct solution to this issue would be be to update dependencies according to this PR: nuxt-community/starter-template#86

Since your comment is so popular (and ranks highly on google for 'nuxt eslint errors') it would be helpful if you could update your comment 🙂

orlandobustamantep added a commit to aluramh/swap-nux that referenced this issue Nov 8, 2018

@lock

This comment has been minimized.

Copy link

commented Nov 22, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Nov 22, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.