Failed to resolve dependencies when starting Nuxt under workspaces
See original GitHub issueEnvironment
- 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
- Create a minimal workspace:
echo '{"private": true, "workspaces": ["app"]}' > package.json
- Create the starter nuxt 3 app inside the same directory:
npx nuxi init app
- 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
- 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
- Run
yarn
to setup the workspace - Test out the workspace’s dev:
yarn workspace app dev
– this works - 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:
- Created a year ago
- Reactions:7
- Comments:14 (7 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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 runyarn why nitropack
and then it should work fine.A workaround for now is to run
yarn nuxi build app
(from the workspace root) rather thanyarn workspace app build
.