nuxt / create-nuxt-app

Create Nuxt.js App in seconds.
MIT License
3.48k stars 429 forks source link

Failed to load plugin errors #754

Open gitjeff05 opened 3 years ago

gitjeff05 commented 3 years ago
MacOS 11.2.3
Node v14.15.3
Yarn 2.4.1

Hello, I've been getting errors after yarn create nuxt-app. Upon running yarn dev I could preview in browser, but then the preview would error out with:

Failed to load plugin 'import' declared in '.eslintrc.js » @nuxtjs/eslint-config': Your application tried to access eslint-plugin-import, but it isn't declared in your dependencies; this makes the require call ambiguous and unsound.

Required package: eslint-plugin-import (via "eslint-plugin-import")
Required by: /Ronnie/million-dollar-ideas/camera-phone

So, I ran yarn add -D eslint-plugin-import and that resolved things. However, as I fixed one dependency, others threw similar errors:

The eslint-plugin-promise error would not go away after installing as dependency. I had to eventually add it to packageExtensions in .yarnrc.yml like so:

packageExtensions:
  eslint-config-standard:
    dependencies:
      eslint-plugin-promise: "*"

This seems to work. But I am wondering if this is the correct way? I'll admit I just upgraded to Yarn 2 and am not completely familiar.

gitjeff05 commented 3 years ago

Upon further examination, yarn was emitting the error YN0002 - MISSING_PEER_DEPENDENCY. Ultimately, I was able to get everything working by adding missing dependencies to my workspace with yarn add and by specifying missing peer dependencies in packageExtensions.

So, errors like:

YN0002: │ project@workspace:. doesn't provide vue (p{xxxx}), requested by @vue/test-utils

can be fixed by adding that dependency to your workspace with yarn add -D vue

and errors like:

YN0002: │ @nuxt/types@npm:2.15.3 doesn't provide webpack (p2e621), requested by sass-loader

can be fixed by adding the following to .yarnrc.yml:

packageExtensions:
  "@nuxt/types@*":
    dependencies:
      webpack: "*"  

Hopefully this can help someone.

clarkdo commented 3 years ago

Hi, create-nuxt-app doesn't support yarn v2 for now, we'll look into this issue.