Failed to make bytecode node14-x64, for a project depends on packages that use .cjs publish mode
See original GitHub issueThis is my first-time use pkg tool and runs into an error and look for help.
I place the demo on : https://github.com/code-brewer/pkg_demo
Nodejs version should >= 12 Because @polkadot/api/index.js and many other files use
importsyntax
Build package
[18:55:21] root@/opt/programming/nodeJs/polka_demo/listent_new_block #pkg -t linux -o ./simple_transfer.exe ./simple_transfer.js
> pkg@5.2.1
> Fetching base Node.js binaries to PKG_CACHE_PATH
fetched-v14.17.0-linux-x64 [====================] 100%
> Warning Failed to make bytecode node14-x64 for file /snapshot/listent_new_block/node_modules/@polkadot/api/index.js
> Warning Failed to make bytecode node14-x64 for file /snapshot/listent_new_block/node_modules/@polkadot/keyring/index.js
> Warning Failed to make bytecode node14-x64 for file /snapshot/listent_new_block/node_modules/@polkadot/api-derive/index.js
> Warning Failed to make bytecode node14-x64 for file /snapshot/listent_new_block/node_modules/@polkadot/metadata/index.js
> Warning Failed to make bytecode node14-x64 for file /snapshot/listent_new_block/node_modules/@polkadot/rpc-core/index.js
> Warning Failed to make bytecode node14-x64 for file /snapshot/listent_new_block/node_modules/@polkadot/rpc-provider/index.js
> Warning Failed to make bytecode node14-x64 for file /snapshot/listent_new_block/node_modules/@polkadot/types/index.js
> Warning Failed to make bytecode node14-x64 for file /snapshot/listent_new_block/node_modules/@polkadot/types-known/index.js
> Warning Failed to make bytecode node14-x64 for file /snapshot/listent_new_block/node_modules/@polkadot/util/index.js
> Warning Failed to make bytecode node14-x64 for file /snapshot/listent_new_block/node_modules/@polkadot/util-crypto/index.js
> Warning Failed to make bytecode node14-x64 for file /snapshot/listent_new_block/node_modules/@polkadot/x-rxjs/index.js
...
Run
On run this exe, it complain that can not find xxx.cjs like module.
I know that @polkadot npm is published to .cjs file, it seem that pkg failed to include these .cjs files, but don’t know how to solve it.
[19:06:59] root@/opt/programming/nodeJs/polka_demo/listent_new_block #
[19:07:01] root@/opt/programming/nodeJs/polka_demo/listent_new_block #./simple_transfer.exe
pkg/prelude/bootstrap.js:1614
throw error;
^
Error: Cannot find module '/snapshot/listent_new_block/node_modules/@polkadot/api/index.cjs'
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 createEsmNotFoundErr (internal/modules/cjs/loader.js:912:15)
at finalizeEsmResolution (internal/modules/cjs/loader.js:905:15)
at resolveExports (internal/modules/cjs/loader.js:437:14)
at Function.Module._findPath (internal/modules/cjs/loader.js:477:31)
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:872:27)
at Function._resolveFilename (pkg/prelude/bootstrap.js:1711:46)
at Function.Module._load (internal/modules/cjs/loader.js:730:27)
at Module.require (internal/modules/cjs/loader.js:957:19)
at Module.require (pkg/prelude/bootstrap.js:1593:31)
at require (internal/modules/cjs/helpers.js:88:18) {
code: 'MODULE_NOT_FOUND',
path: '/snapshot/listent_new_block/node_modules/@polkadot/api/package.json',
pkg: true
}
The demo project run ok if invoke by node ./simple_transfer.js
[19:34:39] root@/opt/programming/nodeJs/polka_demo/listent_new_block #node ./simple_transfer.js
2021-06-02 19:35:30 METADATA: Unknown types found, no types for , ProxyAnnouncement,MaxPending, ProxyDefinition,MaxProxies, WeakVec
Transfer sent with hash 0xef9c37fd5461e971167d53a80f077d334c625003e3c0ba4425d8b54688721408
Issue Analytics
- State:
- Created 2 years ago
- Comments:5
Top Results From Across the Web
Warning Failed to make bytecode #641 - vercel/pkg - GitHub
Hi sven,. Got this error when run with --debug flag.brotli npm package is using emscripten c++ compiler to compile c++ code to javascript ......
Read more >PKG Failed to make Bytecode - Stack Overflow
My Script was written in ES6, I ran it threw Babel and then tried again and it worked perfectly!!
Read more >Building applications with Maven - Quarkus
During the generate-code and generate-code-tests goals the Quarkus application bootstrap is initialized and re-used in the build goal (which actually builds and ...
Read more >Publish Library as an NPM & Github module with CJS & ESM ...
In this tutorial, we will see how we can publish an npm package to the github package respository. Code the node.js project you...
Read more >11.4. Writing a Custom Plugin
To create a plugin project, you should use the Maven Archetype plugin. ... This project depends on version 2.0 of the maven-plugin-api and...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@code-brewer Hi, I have the same issue, have you solved it?
This issue is now closed due to inactivity, you can of course reopen or reference this issue if you see fit.