Can't run project anymore
Hello everyone. I've cloned a project locally, but I cannot start it anymore. I did not change the package.json or the pnpm-lock.
I get the following error:
[12:54:16 PM] ERROR Cannot find package 'pkg-types' imported from /home/ralacerda/.local/share/pnpm/store/v10/links/@nuxt/schema/4.0.0/5b30390c172d5c15b0c03786f97989210b84429d36f17ee7828ca08de7ac5055/node_modules/@nuxt/schema/dist/index.mjs Did you mean to import "pkg-types/dist/index.mjs"? at Object.getPackageJSONURL (node:internal/modules/package_json_reader:268:9) at packageResolve (node:internal/modules/esm/resolve:768:81) at moduleResolve (node:internal/modules/esm/resolve:854:18) at defaultResolve (node:internal/modules/esm/resolve:984:11) at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:685:12) at #cachedDefaultResolve (node:internal/modules/esm/loader:634:25) at ModuleLoader.resolve (node:internal/modules/esm/loader:617:38) at ModuleLoader.getModuleJobForImport (node:internal/modules/esm/loader:273:38) at ModuleJob._link (node:internal/modules/esm/module_job:135:49) [12:54:16 PM] ERROR Cannot find package 'pkg-types' imported from /home/ralacerda/.local/share/pnpm/store/v10/links/@nuxt/schema/4.0.0/5b30390c172d5c15b0c03786f97989210b84429d36f17ee7828ca08de7ac5055/node_modules/@nuxt/schema/dist/index.mjs Did you mean to import "pkg-types/dist/index.mjs"?Here are my dependencies:
7 Replies
Hi @Renato L.. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
Based on the error message and the knowledge sources, this appears to be a dependency resolution issue with the
pkg-types package in your Nuxt 4 project.
The error indicates that @nuxt/schema is trying to import pkg-types, but the package cannot be found in the expected location. This is likely related to how pnpm resolves dependencies in your project.
Recommended Solutions
Based on similar issues in the knowledge sources, here are the steps you should try:
1. Clear your dependencies and reinstall:
2. Try deduplicating your dependencies:
3. Update your pnpm version: The knowledge sources show that Nuxt has been updating to newer pnpm versions (like pnpm v10.9.0 and pnpm v10.11.1). Make sure you're using a recent version of pnpm:
4. Check your Node.js version: According to the StackBlitz issue, updating from Node 20.x to 22.x resolved similar errors for some users. Ensure you're using a compatible Node.js version.
The knowledge sources indicate that there have been updates to pkg-types (from v1.3.1 to v2.0.1), which included breaking changes and improvements to module resolution. This suggests that dependency resolution issues with pkg-types have been addressed in recent Nuxt updates.
If these steps don't resolve the issue, you may need to ensure all your Nuxt-related packages are compatible with Nuxt 4.0.0 and consider updating them to their latest versions.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@343939339094327296> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
Now the error changed to:
ERROR Could not load @nuxt/scripts. Is it installed? 1:00:45 PM at loadNuxtModuleInstance (/home/ralacerda/.local/share/pnpm/store/v10/links/@nuxt/kit/4.2.1/ac7f2d2c1da0945da22ab2d4d9ce028acdb713333e5f906b74c6662f1ecb6004/node_modules/@nuxt/kit/dist/index.mjs:734:13) at async installModules (/home/ralacerda/.local/share/pnpm/store/v10/links/@nuxt/kit/4.2.1/ac7f2d2c1da0945da22ab2d4d9ce028acdb713333e5f906b74c6662f1ecb6004/node_modules/@nuxt/kit/dist/index.mjs:580:17) at async initNuxt (/home/ralacerda/.local/share/pnpm/store/v10/links/nuxt/4.2.1/55bfc044d240c127ed46f302084d226ec72f41c4f8ce0f26607f6296f04e9d17/node_modules/nuxt/dist/index.mjs:5387:3) at async loadNuxt (/home/ralacerda/.local/share/pnpm/store/v10/links/nuxt/4.2.1/55bfc044d240c127ed46f302084d226ec72f41c4f8ce0f26607f6296f04e9d17/node_modules/nuxt/dist/index.mjs:5589:5) at async loadNuxt (/home/ralacerda/.local/share/pnpm/store/v10/links/@nuxt/kit/4.2.1/ac7f2d2c1da0945da22ab2d4d9ce028acdb713333e5f906b74c6662f1ecb6004/node_modules/@nuxt/kit/dist/index.mjs:982:16) at async Object.run (/home/ralacerda/.local/share/pnpm/store/v10/links/@nuxt/cli/3.30.0/112d6e3aeef6f75e32167387f111eb22fbc0c318dba8b37d9625b27b04fdf77f/node_modules/@nuxt/cli/dist/prepare-DjR-jyiQ.mjs:27:16) at async runCommand (/home/ralacerda/.local/share/pnpm/store/v10/links/citty/0.1.6/60049a776d643f917e043408961f8cfc126d28cfbf34bde0da9570c32daacc33/node_modules/citty/dist/index.mjs:316:16) at async runCommand (/home/ralacerda/.local/share/pnpm/store/v10/links/citty/0.1.6/60049a776d643f917e043408961f8cfc126d28cfbf34bde0da9570c32daacc33/node_modules/citty/dist/index.mjs:307:11) at async runMain (/home/ralacerda/.local/share/pnpm/store/v10/links/citty/0.1.6/60049a776d643f917e043408961f8cfc126d28cfbf34bde0da9570c32daacc33/node_modules/citty/dist/index.mjs:445:7) ERROR Could not load @nuxt/scripts. Is it installed? 1:00:45 PM ELIFECYCLE Command failed with exit code 1.But @nuxt/scripts is installed @kapa.ai
Let me check the knowledge base for you again. One moment! :books:
----------------------
Based on the error message and the knowledge sources, this appears to be a module loading issue with
@nuxt/scripts. The error "Could not load /scripts. Is it installed?" suggests that Nuxt is having trouble loading the module even though it's listed in your dependencies.
Understanding the Issue
According to the PR about module compatibility, Nuxt has improved error handling when modules are not compatible with the current version. The knowledge sources mention that "people being surprised by modules (nuxt/scripts) being disabled due to compatibility" has been an issue.
Recommended Solutions
1. Verify the module is properly installed:
2. Check your nuxt.config.ts file: Make sure @nuxt/scripts is correctly registered in your modules array. It should look like:
3. Update to the latest version: Your package.json shows @nuxt/scripts at version 0.11.8. According to the dependency update PR, this version exists, but you might want to try updating to the latest version:
4. Clear cache and reinstall: Since you're using Nuxt 4.2.1, try clearing everything again:
5. Check module compatibility: The knowledge sources indicate that module compatibility checking has been improved in recent Nuxt versions. Your @nuxt/scripts@0.11.8 should be compatible with Nuxt 4, but if the issue persists, there might be a compatibility problem between the module version and your Nuxt version.
If the error persists after these steps, the knowledge sources suggest that this could be related to how the module is being resolved in your specific environment. The error message format indicates this is coming from Nuxt's module loading system, which has been updated to provide better error messages when modules fail to load.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@343939339094327296> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
did you install your dependencies?
is there any parent folder with a
node_modules/ folder?Yeap. I've run
rm -rf node_modules .nuxt rm pnpm-lock.yaml pnpm installThat did not work, so I updated all dependencies, but I kept getting erros for each module. So I disabled them all Still I got the error:
❯ pnpm dev nuxt-app@ dev /home/ralacerda/Repos/website nuxt dev ERROR Cannot read properties of null (reading 'name') 1:57:07 PM at getBuilder (/home/ralacerda/.local/share/pnpm/store/v10/links/@nuxt/cli/3.30.0/07f6648a93c54b93d102a8d1dd2f762b04682c1f4f6ad12a29a874bedb498f77/node_modules/@nuxt/cli/dist/banner-CWBLwDiB.mjs:24:20) at showVersionsFromConfig (/home/ralacerda/.local/share/pnpm/store/v10/links/@nuxt/cli/3.30.0/07f6648a93c54b93d102a8d1dd2f762b04682c1f4f6ad12a29a874bedb498f77/node_modules/@nuxt/cli/dist/banner-CWBLwDiB.mjs:46:18) at NuxtDevServer.init (/home/ralacerda/.local/share/pnpm/store/v10/links/@nuxt/cli/3.30.0/07f6648a93c54b93d102a8d1dd2f762b04682c1f4f6ad12a29a874bedb498f77/node_modules/@nuxt/cli/dist/dev-BYEMtZLe.mjs:365:32) at async initialize (/home/ralacerda/.local/share/pnpm/store/v10/links/@nuxt/cli/3.30.0/07f6648a93c54b93d102a8d1dd2f762b04682c1f4f6ad12a29a874bedb498f77/node_modules/@nuxt/cli/dist/dev-BYEMtZLe.mjs:666:2) at async Object.run (/home/ralacerda/.local/share/pnpm/store/v10/links/@nuxt/cli/3.30.0/07f6648a93c54b93d102a8d1dd2f762b04682c1f4f6ad12a29a874bedb498f77/node_modules/@nuxt/cli/dist/dev-nr2jb3A5.mjs:208:51) at async runCommand (/home/ralacerda/.local/share/pnpm/store/v10/links/citty/0.1.6/6942154b1826e2e0b567a59d92fdd539d81c3f45d8f9355ed493fac839c138fa/node_modules/citty/dist/index.mjs:316:16) at async runCommand (/home/ralacerda/.local/share/pnpm/store/v10/links/citty/0.1.6/6942154b1826e2e0b567a59d92fdd539d81c3f45d8f9355ed493fac839c138fa/node_modules/citty/dist/index.mjs:307:11) at async runMain (/home/ralacerda/.local/share/pnpm/store/v10/links/citty/0.1.6/6942154b1826e2e0b567a59d92fdd539d81c3f45d8f9355ed493fac839c138fa/node_modules/citty/dist/index.mjs:445:7) ERROR Cannot read properties of null (reading 'name') 1:57:07 PM ELIFECYCLE Command failed with exit code 1.I started a new project, installed the packages from scratch, and then copied over the
package.json and pnpm-lock. That fixed it.