Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error [ERR_UNKNOWN_BUILTIN_MODULE]: No such built-in module: express #87

Open
KianoJ opened this issue Jan 17, 2024 · 5 comments
Open

Comments

@KianoJ
Copy link

KianoJ commented Jan 17, 2024

Hello,
I tried to compile my express app following the Single executable applications guide in but I've got this error :

node:internal/util/embedding:48
    throw new ERR_UNKNOWN_BUILTIN_MODULE(id);
    ^

Error [ERR_UNKNOWN_BUILTIN_MODULE]: No such built-in module: express
    at embedderRequire (node:internal/util/embedding:48:11)
    at dist/app.js:141:33
    at embedderRunCjs (node:internal/util/embedding:37:10)
    at node:internal/main/embedding:18:8 {
  code: 'ERR_UNKNOWN_BUILTIN_MODULE'
}

Node.js v21.6.0

It also appear with Node.js v20.10.0.

The app is written with typescript but the build is working when running in the terminal. Here is the tsconfig.json

{
  "compilerOptions": {
    "target": "ES5",
    "lib": ["ES5"],
    "module": "commonjs",
    "rootDir": "./src",
    "sourceMap": true,
    "outDir": "./dist",
    "esModuleInterop": true,
    "forceConsistentCasingInFileNames": true,
    "strict": true,
    "skipLibCheck": true
  }
}

Did I miss something ?

@GabenGar
Copy link

Yeah, the part where it says that it only supports built-in modules.

@joyeecheung
Copy link
Member

joyeecheung commented Jan 18, 2024

Yes, for now you would need to bundle your code into one single file that only requires builtins before injecting it into the SEA.

@KianoJ
Copy link
Author

KianoJ commented Jan 20, 2024

Hooo I didn't understand like that. Thanks for the clarification!
For now if I want to achieve the same results is by using pkg by vercel?

@robertsLando
Copy link

FYI pkg has been archived now. I'm maintaining the most active fork here: https://github.com/yao-pkg/pkg

If you need ESM support there some alternatives: yao-pkg/pkg#16 (comment)

@pironev
Copy link

pironev commented May 14, 2024

This will works if you do a build with just one file.
Install esbuild:
npm install --save-exact --save-dev esbuild
Copy to package.json:

     "scripts": {
     "build": "esbuild your-start-file.js --bundle --platform=node --outfile=out.js"
        }

generate out.js :
npm run build
Then resumes the whole process from https://nodejs.org/api/single-executable-applications.html for out.js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants