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

Errors when importing vue/server-renderer #139

Closed
cjpearson opened this issue Jul 9, 2024 · 0 comments · Fixed by #140
Closed

Errors when importing vue/server-renderer #139

cjpearson opened this issue Jul 9, 2024 · 0 comments · Fixed by #140
Assignees

Comments

@cjpearson
Copy link

The vue/server-renderer export in the vue package re-exports @vue/server-renderer.

Expected Behavior

Applications which import vue/server-renderer will work fine when the import-in-the-middle hook is loaded.

Actual Behavior

When attempting to open the application, the following error is logged:

[nuxt] [request error] [unhandled] [500] The requested module 'vue/server-renderer' does not provide an export named 'renderToString'
  at ModuleJob._instantiate (node:internal/modules/esm/module_job:131:21)
  at async ModuleJob.run (node:internal/modules/esm/module_job:213:5)
  at async ModuleLoader.import (node:internal/modules/esm/loader:316:24)
  at async Object.handler (./.output/server/chunks/runtime.mjs:2861:19)
  at async Server.toNodeHandle (./.output/server/chunks/runtime.mjs:3131:7)
[nuxt] [request error] [unhandled] [500] The requested module 'vue/server-renderer' does not provide an export named 'renderToString'
  at ModuleJob._instantiate (node:internal/modules/esm/module_job:131:21)
  at async ModuleJob.run (node:internal/modules/esm/module_job:213:5)
  at async ModuleLoader.import (node:internal/modules/esm/loader:316:24)
  at async Object.handler (./.output/server/chunks/runtime.mjs:2861:19)
  at async Server.toNodeHandle (./.output/server/chunks/runtime.mjs:3131:7)

Steps to Reproduce the Problem

  1. Create a basic Nuxt app npx nuxi init test-app
  2. Add import-in-the-middle yarn add import-in-the-middle
  3. Build yarn nuxt build
  4. Run with import-in-the-middle node --loader=import-in-the-middle/hook.mjs .output/server/index.mjs

Alternatively, this single-file approach seems to recreate the problem

index.mjs

import { renderToString } from 'vue/server-renderer'

console.log('hello world')
❯ node index.mjs
hello world
❯ node --loader=import-in-the-middle/hook.mjs index.mjs
(node:75208) ExperimentalWarning: `--experimental-loader` may be removed in the future; instead use `register()`:
--import 'data:text/javascript,import { register } from "node:module"; import { pathToFileURL } from "node:url"; register("import-in-the-middle/hook.mjs", pathToFileURL("./"));'
(Use `node --trace-warnings ...` to show where the warning was created)
file:///private/tmp/import-test/index.mjs:1
import { renderToString } from 'vue/server-renderer'
         ^^^^^^^^^^^^^^
SyntaxError: The requested module 'vue/server-renderer' does not provide an export named 'renderToString'
    at ModuleJob._instantiate (node:internal/modules/esm/module_job:131:21)
    at async ModuleJob.run (node:internal/modules/esm/module_job:213:5)
    at async ModuleLoader.import (node:internal/modules/esm/loader:316:24)
    at async loadESM (node:internal/process/esm_loader:34:7)
    at async handleMainPromise (node:internal/modules/run_main:66:12)

Node.js v20.9.0

Specifications

  • Version: 1.9.0 (Node v20.9.0)
  • Platform: MacOS
  • Subsystem:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants