nitro icon indicating copy to clipboard operation
nitro copied to clipboard

Broken build due to missing files from node_modules

Open dulnan opened this issue 3 months ago • 0 comments

Environment

nitropack: 2.12.6 node: 20.19.1

Reproduction

https://stackblitz.com/edit/github-zcdft7zb?file=package.json,server%2Froutes%2Findex.ts

Describe the bug

In dev mode the reproduction will work just fine. The event handler will return the JSON imported from a package. After building and starting the app, the same event handler will throw an error:

cause: Error: Cannot find module '../data/patch.json'

Additional context

This happens because of this import in the event handler:

import data from 'css-tree/definition-syntax-data-patch'

Which looks like this:

import { createRequire } from 'module';

const require = createRequire(import.meta.url);
const patch = require('../data/patch.json');

export default patch;

It's requiring a file called patch.json, which is missing from the output:

~/projects/jvmipzvolv.github/.output/server/node_modules/css-tree
❯ ls -la
total 4
drwxrwxr-x  1  staff  staff     2  Sept  22  13:43  ./             
drwxrwxr-x  1  staff  staff     1  Sept  22  13:43  ../            
drwxrwxr-x  1  staff  staff     1  Sept  22  13:43  lib/           
-rw-r--r--  1  staff  staff  3883  Sept  22  13:43  package.json 

Logs


dulnan avatar Sep 22 '25 11:09 dulnan