PKG Failed to make Bytecode
Asked Answered
E

2

8

I am getting this warning when I try and run .. pkg index.js -t macOS

node v17.3.1 [email protected]

Warning Failed to make bytecode node17-arm64 for file /snapshot/______/index.js

was hoping anyone could help,

I have also tried to use -b and got

Error: ENOENT: no such file or directory, open '/var/folders/fy/c5tgsjcj63q73kfvg_dd53fh0000gn/T/pkg.d5ef9dd92b18360a4ff95824/node/out/Release/node

thank you

Egide answered 14/1, 2022 at 0:44 Comment(1)
See my answer here: https://mcmap.net/q/1355945/-pkg-failed-to-make-bytecodeMcclintock
M
3

I used @vercel/ncc to generate one index.js file and then use pkg on the generated index.js file.

My package.json scripts is like this:

"scripts": {
    "test": "jest",
    "start": "node src/index.js",
    "dev": "nodemon src/index.js",
    "build": "ncc build  -o build/lib ./src/index.js && pkg --target node16-win-x64 -o build/MY-API.exe ./build/lib/index.js"
  },
Mcclintock answered 5/1, 2023 at 13:52 Comment(2)
Worked for me! Thanks. Is there a way to use npx with ncc?Strabismus
@SovatthaSok of course. Just do npx ncc ...Mcclintock
E
2

My Script was written in ES6, I ran it threw Babel and then tried again and it worked perfectly!!

Egide answered 14/1, 2022 at 18:22 Comment(2)
Hi, Can you provide the commands used with babel and configs? I have similar issues.Coquelicot
Hey sorry for late reply. I can't even remember what project this was from .. but im pretty sure I ran the code threw babeljs.io s website and just copy and pasted the results! .. I know it was kinda a hack job.. but it worked for me!Egide

© 2022 - 2024 — McMap. All rights reserved.