vercel/pkg

Failed to make bytecode node18-x64 for file

gareth-johnstone opened this issue · 5 comments

What version of pkg are you using?

5.8.1

What version of Node.js are you using?

18.16.1

What operating system are you using?

Windows 11

What CPU architecture are you using?

x86_64

What Node versions, OSs and CPU architectures are you building for?

node18

Describe the Bug

> pkg release.js --targets node18-win-x64 --out-path dist/Windows-x64

> pkg@5.8.1
> Warning Failed to make bytecode node18-x64 for file C:\snapshot\iqx-releasenotes\release.js
> Warning Failed to make bytecode node18-x64 for file C:\snapshot\iqx-releasenotes\config.js
> Warning Failed to make bytecode node18-x64 for file C:\snapshot\iqx-releasenotes\node_modules\ora\index.js
> Warning Failed to make bytecode node18-x64 for file C:\snapshot\iqx-releasenotes\node_modules\chalk\source\index.js
> Warning Failed to make bytecode node18-x64 for file C:\snapshot\iqx-releasenotes\node_modules\cli-cursor\index.js
> Warning Failed to make bytecode node18-x64 for file C:\snapshot\iqx-releasenotes\node_modules\is-interactive\index.js
> Warning Failed to make bytecode node18-x64 for file C:\snapshot\iqx-releasenotes\node_modules\is-unicode-supported\index.js
> Warning Failed to make bytecode node18-x64 for file C:\snapshot\iqx-releasenotes\node_modules\log-symbols\index.js
> Warning Failed to make bytecode node18-x64 for file C:\snapshot\iqx-releasenotes\node_modules\stdin-discarder\index.js
> Warning Failed to make bytecode node18-x64 for file C:\snapshot\iqx-releasenotes\node_modules\strip-ansi\index.js
> Warning Failed to make bytecode node18-x64 for file C:\snapshot\iqx-releasenotes\node_modules\chalk\source\utilities.js
> Warning Failed to make bytecode node18-x64 for file C:\snapshot\iqx-releasenotes\node_modules\restore-cursor\index.js
> Warning Failed to make bytecode node18-x64 for file C:\snapshot\iqx-releasenotes\node_modules\ansi-regex\index.js

Then when running the produced executable:

release --v 2.23.30
node:internal/modules/cjs/loader:949
  throw err;
  ^

Error: Cannot find module 'C:\snapshot\iqx-releasenotes\release.js'
    at Module._resolveFilename (node:internal/modules/cjs/loader:946:15)
    at Function._resolveFilename (pkg/prelude/bootstrap.js:1951:46)
    at Module._load (node:internal/modules/cjs/loader:787:27)
    at Function.runMain (pkg/prelude/bootstrap.js:1979:12)
    at node:internal/main/run_main_module:17:47 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}

Node.js v18.5.0

Expected Behavior

It gives birth to an executable that works

To Reproduce

see above

I just had this issue and I found it was because I had, incidentally, converted the CJS require() to ES's import(). Have you verified you're using CJS?

I just had this issue and I found it was because I had, incidentally, converted the CJS require() to ES's import(). Have you verified you're using CJS?

Yes, using CJS, i think its producing the error because the npm modules im using is possibly using ES

Yes, same happens with the axios module since they started using ES modules.

I posted a workaround here: #1905

This issue is stale because it has been open 90 days with no activity. Remove the stale label or comment or this will be closed in 5 days. To ignore this issue entirely you can add the no-stale label

For anyone that is interested in this project, I created my own forks of both pkg and pkg-fetch:

yao-pkg/pkg-fetch
yao-pkg/pkg

If someone is interested in helping me create a PR or move your active PR to those repositories.

Thanks 🙏🏼