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.

Failed to resolve dependencies when starting Nuxt under workspaces

See original GitHub issue

Environment


  • Operating System: Darwin
  • Node Version: v17.8.0
  • Nuxt Version: 3.0.0-27490192.4253d2e
  • Package Manager: yarn@1.22.18
  • Builder: vite
  • User Config: -
  • Runtime Modules: -
  • Build Modules: -

Reproduction

  1. Create a minimal workspace: echo '{"private": true, "workspaces": ["app"]}' > package.json
  2. Create the starter nuxt 3 app inside the same directory: npx nuxi init app
  3. Update app/package.json to add a name and version (since yarn 1.x requires this in its workspaces).
    • sed -i '' 's/"private"/"name":"app","version":"1.0.0","private"/' app/package.json
  4. The cwd should look like this:
./app
./app/app.vue
./app/README.md
./app/.gitignore
./app/package.json
./app/nuxt.config.ts
./app/tsconfig.json
./package.json
  1. Run yarn to setup the workspace
  2. Test out the workspace’s dev: yarn workspace app dev – this works
  3. Build: yarn workspace app build – this fails (see logs)

Describe the bug

Unable to build a nuxt 3 app within a yarn 1.x workspace. Development works fine. Build will also work if I nuke the workspace’s node_modules and link it directly to the parent directory’s node_modules.

Additional context

No response

Logs

Nuxt CLI v3.0.0-27490192.4253d2e                                                                              14:58:13
ℹ Client built in 659ms                                                                                       14:58:15
ℹ Vite client warmed up in 661ms                                                                              14:58:15
ℹ Building server...                                                                                          14:58:15
✔ Server built in 241ms                                                                                       14:58:15
✔ Generated public .output/public                                                                       nitro 14:58:15
start Building server...                                                                                nitro 14:58:15

 WARN  '@nuxt/devalue' is imported by ../node_modules/nuxt3/dist/core/runtime/nitro/renderer.mjs, but could not be resolved – treating it as an external dependency


 WARN  '@vue/runtime-dom' is imported by @vue/runtime-dom?commonjs-external, but could not be resolved – treating it as an external dependency


 WARN  '@vue/shared' is imported by @vue/shared?commonjs-external, but could not be resolved – treating it as an external dependency


 ERROR  Rollup error: Could not load vue/server-renderer (imported by .nuxt/dist/server/server.mjs): ENOENT: no such file or directory, open 'vue/server-renderer'


 ERROR  Could not load vue/server-renderer (imported by .nuxt/dist/server/server.mjs): ENOENT: no such file or directory, open 'vue/server-renderer'



error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
error Command failed.
Exit code: 1
Command: /opt/homebrew/Cellar/node/17.8.0/bin/node
Arguments: /opt/homebrew/lib/node_modules/yarn/lib/cli.js build
Directory: /Users/eden/dev/example2/app
Output:

info Visit https://yarnpkg.com/en/docs/cli/workspace for documentation about this command.

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:7
  • Comments:14 (7 by maintainers)

github_iconTop GitHub Comments

5reactions
antfucommented, Apr 25, 2022

It’s fixed in nitropack v0.3.7 (https://github.com/unjs/nitro/commit/458ff5793a6d088c5813a05173a35675f453267d)

You can upgrade it with a clean install (or a version resolution). Make sure it emits v0.3.7 or above then you run yarn why nitropack and then it should work fine.

➜ yarn why nitropack
└─ nuxt@npm:3.0.0-rc.1
   └─ nitropack@npm:0.3.7 (via npm:^0.3.5)
4reactions
danielroecommented, Apr 11, 2022

A workaround for now is to run yarn nuxi build app (from the workspace root) rather than yarn workspace app build.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Nuxt 3 Deploy Failed: Rollup failed to resolve import "vue"
I've tried clearing the cache, redeploying, updating dependencies, etc. But, nothing gives. No public URL is yet available as the site isn't deployed....
Read more >
Unable to resolve dependency tree error when installing npm ...
You have dependency conflict (incorrect and potentially broken dependency) as it says, so try to run the command with --force , or --legacy-peer ......
Read more >
.npmrc | pnpm
Even though all the dependencies will be hard linked into the root node_modules , packages will have access only to those dependencies that...
Read more >
Deploying a Nuxt Site on Netlify between a pnpm monorepo
I started with Lerna in the early phases, I was using it with yarn ... about Failed to resolve entry for package "@pnpm-monorepo-nuxt/ui"....
Read more >
Module not found: Can't resolve 'axios' in React | bobbyhadz
Make sure to restart your development server and your IDE if necessary. Your dev server won't pick up the changes until you stop...
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