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

Failed to resolve import "#build/plugins" when adding alias for @vue/composition-api #12683

Closed
Kunoacc opened this issue Oct 29, 2021 · 2 comments

Comments

@Kunoacc
Copy link

Kunoacc commented Oct 29, 2021

Environment

  • Operating System: Darwin
  • Node Version: v16.11.1
  • Nuxt Version: 3.0.0-27258294.bdbfa36
  • Package Manager: yarn@1.22.15
  • Bundler: Vite
  • User Config: build, vite
  • Runtime Modules: -
  • Build Modules: -

Describe the bug

Adding resolve.alias throws an error on dev and build, Failed to resolve import "#build/plugins" from "node_modules/nuxt3/dist/app/entry.mjs". Does the file exist?

at formatError (node_modules/vite/dist/node/chunks/dep-85dbaaa7.js:42189:46)
  at TransformContext.error (node_modules/vite/dist/node/chunks/dep-85dbaaa7.js:42185:19)
  at normalizeUrl (node_modules/vite/dist/node/chunks/dep-85dbaaa7.js:67281:26)
  at async TransformContext.transform (node_modules/vite/dist/node/chunks/dep-85dbaaa7.js:67421:57)
  at async Object.transform (node_modules/vite/dist/node/chunks/dep-85dbaaa7.js:42396:30)
  at async doTransform (node_modules/vite/dist/node/chunks/dep-85dbaaa7.js:56797:29)


 ERROR  [vite:load-fallback] Could not load  (imported by node_modules/nuxt3/dist/app/entry.mjs): ENOENT: no such file or directory, open '' 

Reproduction

https://codesandbox.io/s/blissful-ellis-37b43?file=/nuxt.config.ts

Create a fresh Nuxt 3 project and copy this into your nuxt.config.js:

import { defineNuxtConfig } from 'nuxt3'

export default defineNuxtConfig({
  vite: {
    resolve: {
      alias: [
        {
          find: /^@vue\/composition-api$/,
          replacement: "@vue/composition-api/dist/vue-composition-api.mjs",
        }
      ],
    },
  },
});

Additional context

This issue with an update to vue-demi prompted me to add the alias resolves

Logs

Failed to resolve import "#build/plugins" from "node_modules/nuxt3/dist/app/entry.mjs". Does the file exist?                                                                  10:49:36

  at formatError (node_modules/vite/dist/node/chunks/dep-85dbaaa7.js:42189:46)
  at TransformContext.error (node_modules/vite/dist/node/chunks/dep-85dbaaa7.js:42185:19)
  at normalizeUrl (node_modules/vite/dist/node/chunks/dep-85dbaaa7.js:67281:26)
  at async TransformContext.transform (node_modules/vite/dist/node/chunks/dep-85dbaaa7.js:67421:57)
  at async Object.transform (node_modules/vite/dist/node/chunks/dep-85dbaaa7.js:42396:30)
  at async doTransform (node_modules/vite/dist/node/chunks/dep-85dbaaa7.js:56797:29)


 ERROR  [vite:load-fallback] Could not load  (imported by node_modules/nuxt3/dist/app/entry.mjs): ENOENT: no such file or directory, open ''                                          10:49:36


 ERROR  Could not load  (imported by node_modules/nuxt3/dist/app/entry.mjs): ENOENT: no such file or directory, open ''                                                               10:49:36



error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
@danielroe danielroe changed the title Failed to resolve import "#build/plugins" Failed to resolve import "#build/plugins" when adding alias for @vue/composition-api Oct 29, 2021
@danielroe
Copy link
Member

danielroe commented Oct 29, 2021

I'm confused - why are you using @vue/composition-api in a vue 3 project?

This seems an issue with how Vite is merging your array and the default Nuxt aliases. For now, you should use the top level alias property rather than directly editing vite.resolve.alias: example.

@danielroe
Copy link
Member

This is no longer reproducible.

@danielroe danielroe added the 3.x label Jan 19, 2023
@danielroe danielroe transferred this issue from nuxt/framework Jan 19, 2023
This was referenced Jan 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants