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

'setupDevtoolsPlugin' is not exported by unenv #13743

Closed
billymaulana opened this issue Apr 13, 2022 · 43 comments · Fixed by nuxt/framework#5874 or nuxt/framework#6713
Closed

'setupDevtoolsPlugin' is not exported by unenv #13743

billymaulana opened this issue Apr 13, 2022 · 43 comments · Fixed by nuxt/framework#5874 or nuxt/framework#6713
Assignees

Comments

@billymaulana
Copy link

billymaulana commented Apr 13, 2022

Environment

NUXT 3 : 3.0.0-27497374.59593a0
NODE : 16.4.2
pnpm": "^6.32.3"

Reproduction

.

Describe the bug

when normaly build its fine.
image

Additional context

my nuxt config not set preset.
when im build NITRO_PRESET=cloudflare pnpm build.

Logs

Error like this:

 ERROR  Rollup error: 'setupDevtoolsPlugin' is not exported by node_modules/.pnpm/unenv@0.4.6/node_modules/unenv/runtime/mock/proxy.mjs, imported by node_modules/.pnpm/pinia@2.0.13_d3195e5b5ca92757b2890fe178df3bd1/node_modules/pinia/dist/pinia.mjs

 ERROR  'setupDevtoolsPlugin' is not exported by node_modules/.pnpm/unenv@0.4.6/node_modules/unenv/runtime/mock/proxy.mjs, imported by node_modules/.pnpm/pinia@2.0.13_d3195e5b5ca92757b2890fe178df3bd1/node_modules/pinia/dist/pinia.mjs

  at error (node_modules/.pnpm/rollup@2.70.1/node_modules/rollup/dist/es/shared/rollup.js:1784:30)
  at Module.error (node_modules/.pnpm/rollup@2.70.1/node_modules/rollup/dist/es/shared/rollup.js:12345:16)
  at Module.traceVariable (node_modules/.pnpm/rollup@2.70.1/node_modules/rollup/dist/es/shared/rollup.js:12703:29)
  at ModuleScope.findVariable (node_modules/.pnpm/rollup@2.70.1/node_modules/rollup/dist/es/shared/rollup.js:11333:39)
  at FunctionScope.findVariable (node_modules/.pnpm/rollup@2.70.1/node_modules/rollup/dist/es/shared/rollup.js:6301:38)
  at ChildScope.findVariable (node_modules/.pnpm/rollup@2.70.1/node_modules/rollup/dist/es/shared/rollup.js:6301:38)
  at Identifier.bind (node_modules/.pnpm/rollup@2.70.1/node_modules/rollup/dist/es/shared/rollup.js:7592:40)
  at CallExpression.bind (node_modules/.pnpm/rollup@2.70.1/node_modules/rollup/dist/es/shared/rollup.js:5166:23)
  at CallExpression.bind (node_modules/.pnpm/rollup@2.70.1/node_modules/rollup/dist/es/shared/rollup.js:8774:15)
  at ExpressionStatement.bind (node_modules/.pnpm/rollup@2.70.1/node_modules/rollup/dist/es/shared/rollup.js:5166:23)
  

image

@danielroe
Copy link
Member

would you provide a reproduction? 🙏

@billymaulana
Copy link
Author

billymaulana commented Apr 13, 2022

n/a

@billymaulana billymaulana changed the title Rollup error: 'setupDevtoolsPlugin' is not exported & 'setupDevtoolsPlugin' Rollup error: 'setupDevtoolsPlugin' is not exported Apr 13, 2022
@pi0
Copy link
Member

pi0 commented Apr 13, 2022

This seems like an issue with pnpm and externals. (unjs/nitro#106)

@pi0 pi0 changed the title Rollup error: 'setupDevtoolsPlugin' is not exported nitro externals issue with pnpm Apr 13, 2022
@aligzl
Copy link

aligzl commented Apr 16, 2022

any updates?

@jontybrook
Copy link
Contributor

I am also seeing this with today's latest v3.0.0-27506609.eed7036

image

@jontybrook
Copy link
Contributor

This seems like an issue with pnpm and externals. (unjs/nitro#106)

I'm using yarn v1.22.18 and also getting this; which indicates to me that it's not pnpm related.

@micheee
Copy link

micheee commented Apr 25, 2022

For the sake of completeness:
I am on yarn too — with the service-worker-Preset on Nuxt CLI v3.0.0-rc.1 and seeing this as well.

start Building server...                                                                                              nitro 16:34:35

 ERROR  Rollup error: 'setupDevtoolsPlugin' is not exported by node_modules/unenv/runtime/mock/proxy.mjs, imported by node_modules/pinia/dist/pinia.mjs


 ERROR  'setupDevtoolsPlugin' is not exported by node_modules/unenv/runtime/mock/proxy.mjs, imported by node_modules/pinia/dist/pinia.mjs

  at error (node_modules/rollup/dist/es/shared/rollup.js:1829:30)
  at Module.error (node_modules/rollup/dist/es/shared/rollup.js:12390:16)
  at Module.traceVariable (node_modules/rollup/dist/es/shared/rollup.js:12748:29)
  at ModuleScope.findVariable (node_modules/rollup/dist/es/shared/rollup.js:11378:39)
  at FunctionScope.findVariable (node_modules/rollup/dist/es/shared/rollup.js:6346:38)
  at ChildScope.findVariable (node_modules/rollup/dist/es/shared/rollup.js:6346:38)
  at Identifier.bind (node_modules/rollup/dist/es/shared/rollup.js:7637:40)
  at CallExpression.bind (node_modules/rollup/dist/es/shared/rollup.js:5211:23)
  at CallExpression.bind (node_modules/rollup/dist/es/shared/rollup.js:8819:15)
  at ExpressionStatement.bind (node_modules/rollup/dist/es/shared/rollup.js:5211:23)

@pi0
Copy link
Member

pi0 commented Apr 25, 2022

@micheee @jontybrook Would you please provide a reproduction? 🙏🏼

@marshallswain
Copy link
Contributor

@pi0 I've provided a reproduction in this issue: #13751

@marshallswain
Copy link
Contributor

@danielroe danielroe changed the title nitro externals issue with pnpm 'setupDevtoolsPlugin' is not exported by unenv Apr 29, 2022
@cinob
Copy link
Contributor

cinob commented Apr 29, 2022

any updates?

@danielroe
Copy link
Member

The cause is that pinia imports setupDevtoolsPlugin from @vue/devtools-api. We deliberately stub out vue devtools on the server. So rollup, in trying to inline this function, fails.

As a workaround, you can do:

import { defineNuxtConfig } from 'nuxt'

export default defineNuxtConfig({
  alias: {
    '@vue/devtools-api': '@vue/devtools-api',
  },
  modules: ['@pinia/nuxt'],
})

@brandonratz
Copy link

@danielroe Thank you for the workaround. Like previously mentioned, I am also using Yarn and not PnPM. My build steps are:

"build": "nuxi build",
"build_cloudflare": "NITRO_PRESET=cloudflare yarn build",

The errors prior to the alias workaround were:

 ERROR  Rollup error: 'setupDevtoolsPlugin' is not exported by node_modules/unenv/runtime/mock/proxy.mjs, imported by node_modules/pinia/dist/pinia.mjs


 ERROR  'setupDevtoolsPlugin' is not exported by node_modules/unenv/runtime/mock/proxy.mjs, imported by node_modules/pinia/dist/pinia.mjs

@marshallswain
Copy link
Contributor

@danielroe does https://stackblitz.com/edit/github-8cjrqx?file=package.json serve as an adequate reproduction? Or do we need a full repo?

@danielroe
Copy link
Member

No need for further reproduction 👍

@igorbelikov
Copy link

igorbelikov commented May 12, 2022

@brandonratz upgrade your yarn version from 1 to 2

https://yarnpkg.com/getting-started/migration#step-by-step

  1. Run yarn set version berry to enable v2 (cf Install for more details)
  1. Run yarn install to migrate the lockfile

and repeat build

@loremru
Copy link

loremru commented Jun 15, 2022

Any news?

@ppodds
Copy link

ppodds commented Jun 29, 2022

Can be reproduced on 3.0.0 rc4 with npm

Update: my problem is caused by vuex. fixed by migrating to pinia.

nuxt.config.ts

import { defineNuxtConfig } from 'nuxt'

export default defineNuxtConfig({
  buildModules: [
    '@pinia/nuxt',
  ],
})

@danielroe
Copy link
Member

Change that to ~4.0.16

@dawidgola
Copy link

thanks, it works !

@acidjazz
Copy link
Contributor

acidjazz commented Jul 7, 2022

So is this a bug that was in vue-router @danielroe ?

@danielroe
Copy link
Member

It's not a bug in vue-router. It and pinia both import @vue/devtools-api for the purpose of client-side integration. But that's not something we want in our server code. It's code that will never be used, so we mock it out in nitro (unenv). Ideally it wouldn't be imported into the node code of either of them. But we can also stub it better.

We've pinned vue-router in future edge/RC releases until we resolve: nuxt/framework#5767

@timmolter
Copy link

I'm getting the same error over and over in an infinite loop until an OOM occurs.

[nuxt] [request error] The requested module 'unenv/runtime/mock/proxy' does not provide an export named 'setupDevtoolsPlugin'
  at ModuleJob._instantiate (node:internal/modules/esm/module_job:128:21)  
  at ModuleJob.run (node:internal/modules/esm/module_job:194:5)  
  at async Promise.all (index 0)  
  at ESMLoader.import (node:internal/modules/esm/loader:409:24)  
  at ./node_modules/nuxt/dist/core/runtime/nitro/renderer.mjs:15:24  
  at ./node_modules/nuxt/dist/core/runtime/nitro/renderer.mjs:70:91  
  at ./.output/server/node_modules/h3/dist/index.mjs:420:19  
  at Server.nodeHandler (./.output/server/node_modules/h3/dist/index.mjs:370:7)

We tried pinning our vue-router to 4.0.16 via "vue-router": "~4.0.16" in 'package.json', but it didn't help.

What else could we try?

@timmolter
Copy link

BTW, as another hint, this problem doesn't occur on our Windows local dev machine, but only when we deploy remotely to Ubuntu 22 LTS.

@cleoledev
Copy link

Just encountered same error today
The solution I addressed is to remove useRoute, useRouter import declarations from <script setup> blocks
It works fine for now

@LoiLock
Copy link

LoiLock commented Jul 13, 2022

Seems like this was fixed 2 hours ago

@pi0
Copy link
Member

pi0 commented Jul 13, 2022

Should be fixed in RC.5. You can remove workarounds.

@tranthotuong
Copy link

image
although, I using nuxt 3 RC5. But I have the same problem, so any solution?

@danielroe
Copy link
Member

Would you ensure you can replicate after running npx nuxi upgrade and if so, open a new issue witha reproduction? 🙏

@tranthotuong
Copy link

Would you ensure you can replicate after running npx nuxi upgrade and if so, open a new issue witha reproduction? 🙏

image
image
After I upgrade, Nuxt runs on ver v3.0.0.rc-6 and nuxi the same. But It is still an error.

@ma-jahn
Copy link

ma-jahn commented Aug 16, 2022

@danielroe

I am experiencing the same after upgrading to nuxt rc8.
After checking the the dependencies linked above (vue-router and pinia) it now looks like it's caused by @nuxtjs/i18n.

Here is a small reproduction repo (Nuxt 3 RC8 + nuxt-i18n): https://stackblitz.com/edit/nuxt-starter-dyand4?file=package.json

@danielroe
Copy link
Member

@ma-jahn I can't reproduce with that stackblitz - it seems to be working fine.

@ma-jahn
Copy link

ma-jahn commented Aug 16, 2022

Hi @danielroe
Thanks for the quick response.

npm run dev (initial command) is working fine.
npm run generateis throwing the following:

 ERROR  [nuxt] [request error] [unhandled] [500] Named export 'setupDevtoolsPlugin' not found. The requested module 'file:///home/projects/nuxt-starter-dyand4/node_modules/unenv/runtime/mock/proxy.cjs' is a CommonJS module, which may not support all module.exports as named exports.
CommonJS modules can always be imported via the default export, for example using:

import pkg from 'file:///home/projects/nuxt-starter-dyand4/node_modules/unenv/runtime/mock/proxy.cjs';
const { setupDevtoolsPlugin } = pkg;

  at async eval (./.nuxt/prerender/chunks/renderer.mjs:12918:24)  
  at async eval (./.nuxt/prerender/chunks/renderer.mjs:12972:64)  
  at async eval (./.nuxt/prerender/chunks/renderer.mjs:33:22)  
  at async eval (./node_modules/h3/dist/index.mjs:571:19)

Could not find how to change the default npm command within that stackblitz 🤷

UPDATE
I've now change the dev command to run generate instead.
So you should see the error right away ✌️

@ma-jahn
Copy link

ma-jahn commented Aug 17, 2022

Just upgraded to v3.0.0-rc.8-27679173.c688e18 and it's working!

@danielroe @pi0 Thank you so much for this blazing fast fix!

@Erica-lyj
Copy link

The cause is that pinia imports setupDevtoolsPlugin from @vue/devtools-api. We deliberately stub out vue devtools on the server. So rollup, in trying to inline this function, fails.

As a workaround, you can do:

import { defineNuxtConfig } from 'nuxt'

export default defineNuxtConfig({
  alias: {
    '@vue/devtools-api': '@vue/devtools-api',
  },
  modules: ['@pinia/nuxt'],
})

i fail, but in this way success

  import { defineNuxtConfig } from 'nuxt'
  export default defineNuxtConfig({
    buildModules: ['@pinia/nuxt'],
    alias: {
      '@vue/devtools-api': '@vue/devtools-api',
    },
 })

i use npm
must execute the command

npm install pinia @pinia/nuxt @nuxtjs/composition-api --legacy-peer-deps

@danielroe
Copy link
Member

You should definitely not install @nuxtjs/composition-api in a Nuxt 3 project. Make sure you are using the latest version of the pinia module.

@Erica-lyj
Copy link

thanks, after I uninstalled @nuxtjs/composition-api, the packaging was still successful

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