Skip to content

Named export 'defu' not found #558

@DesertCookie

Description

@DesertCookie

I created a fresh Nuxt project using bun and installed PWA. When I run the application via npm run dev, I get the following error:

 ERROR  Named export 'defu' not found. The requested module 'defu' 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 'defu';
const { defu } = pkg;


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

  at ModuleJob._instantiate (node:internal/modules/esm/module_job:171:21)
  at async ModuleJob.run (node:internal/modules/esm/module_job:254:5)
  at async onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:482:26)
  at async loadKit (/C:/Users/PROJECT_PATH/node_modules/nuxi/dist/shared/nuxi.f76c700d.mjs:5049:15)
  at async Object.run (/C:/Users/PROJECT_PATH/node_modules/nuxi/dist/chunks/dev.mjs:170:32)
  at async runCommand$1 (/C:/Users/PROJECT_PATH/node_modules/nuxi/dist/shared/nuxi.fefc5017.mjs:1648:16)
  at async runCommand$1 (/C:/Users/PROJECT_PATH/node_modules/nuxi/dist/shared/nuxi.fefc5017.mjs:1639:11)
  at async runMain$1 (/C:/Users/PROJECT_PATH/node_modules/nuxi/dist/shared/nuxi.fefc5017.mjs:1777:7)

This is my package.json:

{
  "name": "project",
  "private": true,
  "type": "module",
  "scripts": {
    "build": "nuxt build",
    "dev": "nuxt dev --tunnel",
    "generate": "nuxt generate",
    "preview": "nuxt preview",
    "postinstall": "nuxt prepare"
  },
  "dependencies": {
    "nuxt": "^3.13.0",
    "vue": "latest",
    "vue-router": "latest"
  },
  "devDependencies": {
    "@nuxtjs/pwa": "^3.3.5"
  }
}

My nuxt.config.ts:

export default defineNuxtConfig({
	devtools: {enabled: true},
	buildModules: [
		'@nuxtjs/pwa',
	],
	pwa: {
		manifest: {
			name: 'Immo-Projektmanagement',
			short_name: 'ImmoM',
			description: '',
			lang: 'de'
		},
		workbox: {},
		mobileAppIOS: true
	},
	compatibilityDate: '2024-09-09'
})

I was in the process of migrating an app to a PWA and had started a new project for that purpose to slowly transition all aspects of the app.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions