Skip to content

Nitro does not respect module path (e.g. in monorepo) with target: server #11465

@TheAlexLichter

Description

@TheAlexLichter

Hey all!

When using Nitro with target: server and a monorepo (see repo structure), the Nitro output does not include the correct path to the deps (e.g. un fetch polyfill)

Repo: https://github.com/manniL/nitro-server-monorepo-dep-path

Repro

  1. Install deps yarn
  2. Build app yarn build
  3. Check packages/app/.output/server/index.js. Here, the path is set correct (../../../../node_modules/@nuxt/un/runtime/polyfill/fetch.node.js in our case)
  4. Now check packages/app/.output/server/nitro/server.js. The path incorrect here
  5. Same for packages/app/.output/server/nitro/chunks/app/render.js

Expected path: require('../../../../../node_modules/@nuxt/un/runtime/polyfill/fetch.node.js');
Actual path: require('../../../../node_modules/@nuxt/un/runtime/polyfill/fetch.node.js');

When fixing the paths manually, the app runs as expected

Workaround?

Using nohoist for the packages might work.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions