question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can't use ipx in serverMiddleware with @nuxt/bridge

See original GitHub issue

When adding /server/middleware/ipx.js to nuxt.config.js (as indicated at https://image.nuxtjs.org/providers/ipx/#advanced-custom-servermiddleware) while using @nuxt/bridge

import { createIPX, createIPXMiddleware } from 'ipx'
const ipx = createIPX({
  dir: '',
  domains: [],
  alias: {},
  sharp: {},
})
export default createIPXMiddleware(ipx)

it results in an error:

 WARN  [worker] Named export 'stat' not found. The requested module 'fs-extra' 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 'fs-extra';
const { stat, readFile } = pkg;


  import { stat, readFile } from 'fs-extra';
  ^^^^
  SyntaxError: Named export 'stat' not found. The requested module 'fs-extra' 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 'fs-extra';
  const { stat, readFile } = pkg;

  at ModuleJob._instantiate (internal/modules/esm/module_job.js:121:21)
  at async ModuleJob.run (internal/modules/esm/module_job.js:166:5)
  at async Loader.import (internal/modules/esm/loader.js:178:24)
  at async Object.loadESM (internal/process/esm_loader.js:68:5)

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:6
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
ms-fadaeicommented, Oct 21, 2021

@pi0, Can we use this pattern?

- import { readFile, stat, Stats } from 'fs-extra'
+ import fsExtra, { Stats } from 'fs-extra'
+ const { stat, readFile } = fsExtra;
1reaction
nathanchasecommented, Jan 8, 2022

This is still unfortunately the only thing that is holding me back from using @nuxt/bridge. Is /server/middleware no longer viable in Nuxt 3 or Bridge?

Read more comments on GitHub >

github_iconTop Results From Across the Web

The serverMiddleware Property - Nuxt
This allows you to create a client API/server API pattern using Nuxt alone. This means that from the browser (for example, within a...
Read more >
Nuxt - server middleware not working on production
I have builded an app using Nuxt and I have created simply server middleware for handling email sending. Everything is working on dev...
Read more >
My take on using Nuxt with an API - Alexander Lichter's blog
There are three common ways to integrate an API with Nuxt. In this blog post, I'll share my personal opinion regarding all of...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found