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

[3.8.0] ERROR Cannot start nuxt: kit.writeTypes is not a function #157

Closed
imcm7 opened this issue Sep 8, 2023 · 21 comments · Fixed by #158
Closed

[3.8.0] ERROR Cannot start nuxt: kit.writeTypes is not a function #157

imcm7 opened this issue Sep 8, 2023 · 21 comments · Fixed by #158

Comments

@imcm7
Copy link

imcm7 commented Sep 8, 2023

Environment

Nuxt project info: 8:15:37 AM


  • Operating System: Linux
  • Node Version: v20.5.0
  • Nuxt Version: 3.7.1
  • CLI Version: 3.8.0
  • Nitro Version: 2.6.3-28235083.5639f5b
  • Package Manager: pnpm@8.7.1
  • Builder: -
  • User Config: -
  • Runtime Modules: @hebilicious/authjs-nuxt@0.2.0-beta.8
  • Build Modules: -

Reproduction

New instaled nuxt with modules

Describe the bug

ERROR Cannot start nuxt: kit.writeTypes is not a function 8:14:17 AM

Additional context

No response

Logs

No response

@Hebilicious
Copy link
Member

Hebilicious commented Sep 8, 2023

@imcm7 You can remove these resolutions if you are using a recent version of Nuxt. In the meantime you should be able to make it work by downgrading to nuxt 3.7.0.
@danielroe was there any change related to writeTypes ? Maybe nuxt/nuxt#22385 ? The only kit utility related to types I'm using in this module is addTypeTemplate, is there anything I can do in the module ?

@pi0 pi0 transferred this issue from nuxt/nuxt Sep 8, 2023
@Hebilicious
Copy link
Member

Related Hebilicious/authjs-nuxt#90

@LeCoupa
Copy link

LeCoupa commented Sep 8, 2023

I also get the same error when updating to nuxt@3.6.5 to nuxt@3.7.1. (also using pnpm)

Same error for 3.7.0. Here is my config.

- Operating System: `Darwin`
- Node Version:     `v20.5.0`
- Nuxt Version:     `3.6.5`
- Nitro Version:    `2.5.2`
- Package Manager:  `pnpm@8.6.2`
- Builder:          `vite`
- User Config:      `build`, `devServer`, `experimental`, `nitro`, `imports`, `runtimeConfig`, `vite`, `components`, `css`, `modules`, `app`, `typescript`, `devtools`, `i18n`, `pinia`, `plausible`, `pwa`
- Runtime Modules:  `@nuxtjs/color-mode@3.3.0`, `@nuxtjs/i18n@8.0.0-rc.3`, `@pinia/nuxt@0.4.11`, `@unocss/nuxt@0.55.7`, `@vite-pwa/nuxt@0.1.0`, `@vueuse/nuxt@10.4.1`, `@nuxtjs/plausible@0.2.3`, `floating-vue/nuxt`, `vue-recaptcha/nuxt`
- Build Modules:    `-`

@pi0
Copy link
Member

pi0 commented Sep 8, 2023

Can anyone make a runnable reproduction? 🙏 it would help a lot to quickly deliver a hotfix.

@PalmerEk
Copy link

PalmerEk commented Sep 8, 2023

I have a WIP project that has the issue https://github.com/PalmerEk/qvhs-programs/tree/main

I tried reverting nuxt back to 3.7.0 to no avail.

npx nuxi dev = ERROR Cannot start nuxt: kit.writeTypes is not a function

npx nuxi@3.7.3 dev = works

@Maximus1000
Copy link

I have same issue in upgrading from 3.6.5 to 3.7.1 (also occurs on 3.7.0), can't build the project with npm run dev, error of kit.writeTypes is not a function. When I create a fresh project using 3.7.1, project builds correctly. I was not able to replicate the issue in the new project *3.7.1 even after bringing over all code from my failing project (excluding nuxt and node_modules folders). Fresh install with my old code built successfully.

The issue for me seems to be on account of missing items from @nuxt/kit/dist/index.d.ts between the 2 projects. In the working project, that file has about 40 more lines of code including this line:
declare function writeTypes(nuxt: Nuxt): Promise<void>;

In the failing project, that index.d.ts file doesn't have any reference to a writeTypes function. writeTypes is separately referenced as you all know by nitropack, but it seems like the error kit.writeTypes is not a function might relatte to the fact that @nuxt/kit is missing any reference to a writeTypes function in the failing project.

I replicated the error in my failing project in both GitBash and PowerShell after running the typical removal of package-lock, node_modules, and doing a force clean of npm's cache. I'm trying yarn and pnpm now to see if I can get either of those to pull down the @nuxt/kit with the correct def for writeTypes function.

Also, separately, I had issue installing with the standard npx nuxi command in GitBash (separate issue with the CLI) but it did work in PowerShell.

@Hebilicious
Copy link
Member

Hebilicious commented Sep 8, 2023

@PalmerEk I was able to run your program by cloning, deleting the lockfile and running bun i && bun dev. Is there any other step to reproduce ?
Is it safe to assume this is a lockfile issue ?

@pi0
Copy link
Member

pi0 commented Sep 8, 2023

Thanks for all the updates and context. Let's hope it is a lockfile issue, yet it is unacceptable behavior from CLI for me. I will spend some time to investigate this better.

@PalmerEk
Copy link

PalmerEk commented Sep 8, 2023

@PalmerEk I was able to run your program by cloning, deleting the lockfile and running bun i && bun dev. Is there any other step to reproduce ? Is it safe to assume this is a lockfile issue ?

npx nuxi cleanup && rm -rf ./node_modules/ && rm package-lock.json && npm i && npm run dev: Error
Cloned the project into a clean folder: Error
cloned into clean folder, deleted lockfile and ran bun i && bun dev: Error

Tried clearing npm cache as well, no dice

@Hebilicious
Copy link
Member

Hebilicious commented Sep 8, 2023

@PalmerEk I was able to run your program by cloning, deleting the lockfile and running bun i && bun dev. Is there any other step to reproduce ? Is it safe to assume this is a lockfile issue ?

npx nuxi cleanup && rm -rf ./node_modules/ && rm package-lock.json && npm i && npm run dev: Error Cloned the project into a clean folder: Error cloned into clean folder, deleted lockfile and ran bun i && bun dev: Error

Tried clearing npm cache as well, no dice

Unable to reproduce this 😢 Does the error show up for you in the console immediately after you runnuxi dev ? Can you reproduce it in Stackblitz/Codesanbox ?

image

@PalmerEk
Copy link

PalmerEk commented Sep 8, 2023

image

Don't think I mentioned it earlier, but this was an "upgraded" project

@reneonguitar
Copy link

reneonguitar commented Sep 8, 2023

I get the same error with a brand new vanilla Nuxt install on MacOS Ventura 13.5.2, node 18.16.0, and npm 9.5.1. See steps below.

[BEGIN]

*** STEP 1 ***

npx nuxi@latest init my-project-here

✔ Which package manager would you like to use?
npm
◐ Installing dependencies...

postinstall
nuxt prepare

✔ Types generated in .nuxt

added 849 packages, and audited 851 packages in 42s

143 packages are looking for funding
run npm fund for details

found 0 vulnerabilities
✔ Installation completed.

✨ Nuxt project has been created with the v3 template. Next steps:
› cd my-project-here
› Start development server with npm run dev

*** STEP 2 ***

cd my-project-here
npm run dev

dev
nuxt dev

Nuxt 3.7.1 with Nitro 2.6.3

➜ Local: http://localhost:3000/
➜ Network: use --host to expose

✔ Nuxt DevTools is enabled v0.8.3 (experimental)

ERROR Cannot start nuxt: kit.writeTypes is not a function

at NuxtDevServer._load (node_modules/nuxi/dist/chunks/dev.mjs:230:11)
at async NuxtDevServer.load (node_modules/nuxi/dist/chunks/dev.mjs:161:7)
at async NuxtDevServer.init (node_modules/nuxi/dist/chunks/dev.mjs:156:5)
at async Object.run (node_modules/nuxi/dist/chunks/dev-child.mjs:91:5)
at async runCommand$1 (node_modules/nuxi/dist/shared/nuxi.913ed971.mjs:1645:5)
at async runCommand$1 (node_modules/nuxi/dist/shared/nuxi.913ed971.mjs:1639:7)
at async runMain$1 (node_modules/nuxi/dist/shared/nuxi.913ed971.mjs:1757:7)

[END]

Please advise as I have to get a new project up and delivered to a colleague to start working on tomorrow; am blocked until then. Thanks, all.

UPDATE

My other working Nuxt apps are on 3.6.5, so I tried this:

[BEGIN AGAIN]

*** STEP 1 ***

npx nuxi@3.6.5 init my-project-here

Need to install the following packages:
nuxi@3.6.5
Ok to proceed? (y)
Nuxi 3.6.5
✨ Nuxt project is created with v3 template. Next steps:
› cd my-project-here
› Install dependencies with npm install or yarn install or pnpm install
› Start development server with npm run dev or yarn dev or pnpm run dev

*** STEP 2 ***

cd my-project-here
npm install

postinstall
nuxt prepare

✔ Types generated in .nuxt

added 849 packages, and audited 851 packages in 48s

143 packages are looking for funding
run npm fund for details

found 0 vulnerabilities

*** STEP 3 ***

npm run dev

dev
nuxt dev

Nuxt 3.7.1 with Nitro 2.6.3

➜ Local: http://localhost:3000/
➜ Network: use --host to expose

✔ Nuxt DevTools is enabled v0.8.3 (experimental)

ERROR Cannot start nuxt: kit.writeTypes is not a function

at NuxtDevServer._load (node_modules/nuxi/dist/chunks/dev.mjs:230:11)
at async NuxtDevServer.load (node_modules/nuxi/dist/chunks/dev.mjs:161:7)
at async NuxtDevServer.init (node_modules/nuxi/dist/chunks/dev.mjs:156:5)
at async Object.run (node_modules/nuxi/dist/chunks/dev-child.mjs:91:5)
at async runCommand$1 (node_modules/nuxi/dist/shared/nuxi.913ed971.mjs:1645:5)
at async runCommand$1 (node_modules/nuxi/dist/shared/nuxi.913ed971.mjs:1639:7)
at async runMain$1 (node_modules/nuxi/dist/shared/nuxi.913ed971.mjs:1757:7)

[END]

The only thing I can think of that's different is this "v3 template" it refers to. I don't remember seeing that when I did my 3.6.5 installs before, but I could be mistaken.

@Hebilicious
Copy link
Member

Hebilicious commented Sep 8, 2023

@PalmerEk @reneonguitar Might be a shot in the dark, but some users have reported that updating node to v20+ worked for them 🤷🏽

@reneonguitar
Copy link

@PalmerEk @reneonguitar Might be a shot in the dark, but some users have reported that updating node to v20+ worked for them 🤷🏽

Sadly, this doesn't work for me either. Behold...

image

Same Nuxt steps as before...

image

@Hebilicious
Copy link
Member

@PalmerEk @reneonguitar Might be a shot in the dark, but some users have reported that updating node to v20+ worked for them 🤷🏽

Sadly, this doesn't work for me either. Behold...

image Same Nuxt steps as before... image

I feel your frustration, the best way to get this sorted would be to provide a reproduction... which seems hard as it doesn't seems to happen on every device. I assume that if you use stackblitz/codesanbox, everything works fine, so that is something happening on your end... The only thing I can think of would be deleteting lockfiles, caches, node_modules, parent node_modules, and using bun.

@reneonguitar
Copy link

@PalmerEk @reneonguitar Might be a shot in the dark, but some users have reported that updating node to v20+ worked for them 🤷🏽

Sadly, this doesn't work for me either. Behold...
image
Same Nuxt steps as before...
image

I feel your frustration, the best way to get this sorted would be to provide a reproduction... which seems hard as it doesn't seems to happen on every device. I assume that if you use stackblitz/codesanbox, everything works fine, so that is something happening on your end... The only thing I can think of would be deleteting lockfiles, caches, node_modules, parent node_modules, and using bun.

Indeed, stackblitz shows node 16.20.0 and npm 9.4.2 while codesandbox shows node 16.17.0 and npm and 8.15.0 in their working sandboxes of Nuxt 3. I moved up from node 16 to 18 recently because of AWS Lambda's upcoming deprecation of 16, but I may need to use split versions between frontend Nuxt and backend Lambdas if I can get 16 to work with Nuxt to get over my immediate hurdle. I'm not surprised by these things anymore...

@justin-schroeder
Copy link

I was working on improving tree shaking in FormKit today — I updated nuxi and other dependencies (locally) and started getting this error. However — I seem to be unable to reproduce this in relative isolation.

Node version: 18.17.1
OS: macOS

Setup:

git clone --single-branch --branch feature/improved-tree-shaking git@github.com:formkit/formkit.git

cd formkit

pnpm install

pnpm build

cd packages/nuxt

pnpm dev

The following error is returned for me:

image

❤️ — you all rock, thank you for the support!

@pi0 pi0 changed the title ERROR Cannot start nuxt: kit.writeTypes is not a function [3.8.0] ERROR Cannot start nuxt: kit.writeTypes is not a function Sep 8, 2023
@pi0
Copy link
Member

pi0 commented Sep 8, 2023

Sorry for all the inconvenience this might have caused to you. The regression was about CLI compatibility with Nuxt < 3.7 which will be solved soon (#158)

@pi0 pi0 closed this as completed in #158 Sep 8, 2023
@pi0
Copy link
Member

pi0 commented Sep 8, 2023

@justin-schroeder checking your reproduction, it seems outdated nuxt causes other issues. I recommend running at least pnpm upgrade nuxt as well (or better refresh lockfile). In case of other issues feel free to open an upgrade PR and ping me would be happy to help.

(same for others if still facing any issues and your repo is public)

@reneonguitar
Copy link

@justin-schroeder checking your reproduction, it seems outdated nuxt causes other issues. I recommend running at least pnpm upgrade nuxt as well (or better refresh lockfile). In case of other issues feel free to open an upgrade PR and ping me would be happy to help.

(same for others if still facing any issues and your repo is public)

Sorry for all the inconvenience this might have caused to you. The regression was about CLI compatibility with Nuxt < 3.7 which will be solved soon (#158)

Great, I see the issue is closed. How does one try it out? Thanks.

@reneonguitar
Copy link

@pi0 nevermind my question about trying it out. i see it was as simple as recreating a new project:

image

And I can confirm npm run dev now works. Thanks for all the help and the quick fix.

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.

8 participants