nuxt: 'setupDevtoolsPlugin' is not exported by `unenv`

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

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 4
  • Comments: 43 (20 by maintainers)

Most upvoted comments

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'],
})

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!

on RC4 and yarn 1.x, when i do the suggested workaround, when running a build (node .output/server/index.mjs) the errors changes to __VUE_PROD_DEVTOOLS__ is not defined. I do not use Vuex (only Pinia).

I tried migrating to yarn 3.2, it did not change the issue.

It’s fine in developement (yarn dev).

[nuxt] [request error] __VUE_PROD_DEVTOOLS__ is not defined
  at Object.install (./.output/server/chunks/app/server.mjs:2996:13)  
  at Object.use (./.output/server/chunks/handlers/renderer.mjs:5786:29)  
  at ./.output/server/chunks/app/server.mjs:19030:18  
  at fn (./.output/server/chunks/app/server.mjs:3723:27)  
  at Object.callAsync (./.output/server/chunks/app/server.mjs:3484:19)  
  at callWithNuxt (./.output/server/chunks/app/server.mjs:3725:23)  
  at applyPlugin (./.output/server/chunks/app/server.mjs:3685:39)  
  at applyPlugins (./.output/server/chunks/app/server.mjs:3694:11)  
  at async createNuxtAppServer (./.output/server/chunks/app/server.mjs:19471:7)  
  at async Object.renderToString (./.output/server/chunks/handlers/renderer.mjs:270:19)

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

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: https://github.com/nuxt/framework/pull/5767

Change that to ~4.0.16

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.

I have the same problem

[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 async ModuleJob.run (node:internal/modules/esm/module_job:194:5)  
  at async Promise.all (index 0)  
  at async ESMLoader.import (node:internal/modules/esm/loader:385:24)  
  at async ./server/chunks/handlers/renderer.mjs:11152:24  
  at async ./server/chunks/handlers/renderer.mjs:11208:64  
  at async ./server/node_modules/h3/dist/index.mjs:420:19  
  at async Server.nodeHandler (./server/node_modules/h3/dist/index.mjs:370:7)

any solution ?

Any news?

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

image

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.

@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

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

No need for further reproduction 👍

@pi0 I’ve provided a reproduction in this issue: https://github.com/nuxt/nuxt.js/issues/13751