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.

loadNuxt not found

See original GitHub issue

Environment

  • Operating System: Linux
  • Node Version: v16.13.0
  • Nuxt Version: 3.0.0-27274229.29599f0
  • Package Manager: npm@8.1.0
  • Bundler: Vite
  • User Config: publicRuntimeConfig, buildModules, intlify
  • Runtime Modules: -
  • Build Modules: @intlify/nuxt3@0.1.8, nuxt-windicss@2.0.12

Describe the bug

nuxt-windicss use @nuxt/kit: latest as a dependency. As soon as I download the package nuxt-windicss, my app cannot start and throws an error “loadNuxt not found”.

In packages/nuxi/src/utils/kit.ts, we have the function loadKit. This function is called in packages/nuxi/src/commands/dev.ts at line 36

const { loadNuxt, buildNuxt } = await loadKit(rootDir)

The problem is that loadKit returns a default key. So we should either do

const { default as defaultKit } = await loadKit(rootDir)
const { loadNuxt, buildNuxt } = defaultKit

Or change packages/nuxi/src/utils/kit.ts with

import { importModule } from './cjs'

export const loadKit = async (rootDir: string): Promise<typeof import('@nuxt/kit')> => {
  try {
    const module = await importModule('@nuxt/kit', rootDir) as typeof import('@nuxt/kit')
    return module.default
  } catch (e) {
    if (e.toString().includes("Cannot find module '@nuxt/kit'")) {
      throw new Error('nuxi requires `@nuxt/kit` to be installed in your project. Try installing `nuxt3` or `@nuxt/bridge` first.')
    }
    throw e
  }
}

Reproduction

The problem comes from the last version of nuxt-windicss which uses @nuxt/kit: latest. Reproduction: npx nuxi init nuxt3-app

Then add in package.json, devDependencies -> “nuxt-windicss”: “^2.0.12”

npm run dev fails with “Cannot start nuxt: loadNuxt is not a function”

Additional context

No response

Logs

No response

Issue Analytics

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

github_iconTop GitHub Comments

2reactions
pi0commented, Nov 18, 2021

Hi. To avoid mixed syntax issues I removed CJS support from @nuxt/kit stub in 0.8.0-edge so it is identical to @nuxt/kit-edge now.

The issue with the CJS default export should be gone if you recreate the lock file (Using npx nuxi upgrade --force)

If still having issues after upgrading, please mention.

1reaction
jbmollecommented, Nov 18, 2021

@pi0 you rock! Thanks a lot, it’s all good

Read more comments on GitHub >

github_iconTop Results From Across the Web

nuxi build Could not load server.mjs #1548 - nuxt/framework
I have tried this on both my local development environment and a remote AWS Amplify instance. Both environments present the same error. Logs....
Read more >
Load Nuxt project to exist express app - vue.js - Stack Overflow
Could not find a trace over the network. Is there a way to load Nuxt project as a middleware for other express server?...
Read more >
[Solved]-Load Nuxt project to exist express app-Vue.js
Coding example for the question Load Nuxt project to exist express app-Vue.js. ... vue-socket.io app not receiving emit from express socket.io app ...
Read more >
Nuxt configuration file
The runtime config is added to the Nuxt payload so there is no need to rebuild in order to update the runtime configuration...
Read more >
Nuxt with Express. Having issues in getting started with…
This will throw an error saying that cross-env is not installed, and also if there any other package ... const nuxt = await...
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