четверг, 25 марта 2021 г.

Package JavaScript code with Node.js in one executable file using PKG

Package JavaScript code with Node.js in one executable file using PKG.

1) Install library PKG:

npm install pkg

2) Open in your code editor file node_modules/pkg/lib-es5/fabricator.js

3) Find in this file row:

child = children[key] = (0, _child_process.spawn)(cmd, bakes.concat('-e', script), {

4) After this row add line of code to fix administarrtor rights problem:

shell: true,

5) Save your changes in file node_modules/pkg/lib-es5/fabricator.js

6) Open command line ("CMD") and type in it:

cd "... here is path to folder with your source code..."

Then press button "Enter" on your keyboard.

7) Then type in command line:

set NODE_TLS_REJECT_UNAUTHORIZED=0

and press "Enter" again.

This will fix SSL problem.

(If your want to run PKG library from your custom source code you can also write in it:

process.env["NODE_TLS_REJECT_UNAUTHORIZED"] = 0;

to do the same.)

8) Then type in command line for example:

node "D:\Work\Your application\node_modules\pkg\lib-es5\bin.js" your-start-file.js --debug --targets node14-windows-x64

to package your JavaScript application files together with Node.js in one executable file.


Комментариев нет:

Отправить комментарий