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

Can't run after packed with pkg #228

Open
bcmRayCrazy-coder opened this issue Jan 11, 2023 · 3 comments
Open

Can't run after packed with pkg #228

bcmRayCrazy-coder opened this issue Jan 11, 2023 · 3 comments

Comments

@bcmRayCrazy-coder
Copy link

I just packed my code directly using pkg
But I can't launch it, 艹
Error below:

node:internal/modules/cjs/loader:933
  const err = new Error(message);
              ^

Error: Cannot find module './termconfig/xterm.generic.js'
Require stack:
- /snapshot/fr/node_modules/terminal-kit/lib/Terminal.js
- /snapshot/fr/node_modules/terminal-kit/lib/termkit.js
- /snapshot/fr/dist/main.js
- /snapshot/fr/entry.js
1) If you want to compile the package/file into executable, please pay attention to compilation warnings and specify a literal in 'require' call. 2) If you don't want to compile the package/file into executable and want to 'require' it from filesystem (likely plugin), specify an absolute path in 'require' call using process.cwd() or process.execPath.
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
    at Function._resolveFilename (pkg/prelude/bootstrap.js:1955:46)
    at Function.Module._load (node:internal/modules/cjs/loader:778:27)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at Module.require (pkg/prelude/bootstrap.js:1855:31)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.createTerminal (/snapshot/fr/node_modules/terminal-kit/lib/Terminal.js:161:18)
    at Object.getDetectedTerminal (/snapshot/fr/node_modules/terminal-kit/lib/detectTerminal.js:354:22)
    at /snapshot/fr/dist/main.js
    at new Promise (<anonymous>) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/snapshot/fr/node_modules/terminal-kit/lib/Terminal.js',
    '/snapshot/fr/node_modules/terminal-kit/lib/termkit.js',
    '/snapshot/fr/dist/main.js',
    '/snapshot/fr/entry.js'
  ],
  pkg: true
}
@whalemare
Copy link

Same issue. Building with nx and @nrwl/esbuild:esbuild

@whalemare
Copy link

whalemare commented Jan 21, 2023

@bcmRayCrazy-coder I think I realize.

You need to say to your bundler that this library in using local imports and it should be external.
In esbuild I have this option. Rollup have this option too, maybe it can help in your case.

My config for nx.dev

{
// ...
  "projectType": "application",
  "targets": {
    "build": {
      "executor": "@nrwl/esbuild:esbuild",
      "outputs": ["{options.outputPath}"],
      "options": {
        "outputPath": "dist/apps/react-native-deploy",
        "format": ["cjs"],
        "main": "apps/react-native-deploy/src/main.ts",
        "tsConfig": "apps/react-native-deploy/tsconfig.app.json",
        "assets": [
          "apps/react-native-deploy/src/assets"
        ],

        // >>>>>>> this lines below for you
        "external": [
          "terminal-kit"
        ]

      }
    },
   // ....
}

@WilliamRelken
Copy link

I am experiencing the same issue packaging terminal kit. I reached the same error after setting --external:terminal-kit in esbuild.

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

3 participants