S
S
sidorikv2022-01-19 22:40:13
Node.js
sidorikv, 2022-01-19 22:40:13

Why am I getting errors when building a node.js app via pkg?

I'm getting errors when building an application via PKG.
This is how my package.json file looks like:
61e86872208bb973410768.png
This is how my index.js file (entry point) looks like:
61e86887705dd518945357.png
I get errors while compiling the project:
61e868d7c8a21776325282.png
I didn't find a lot of information on the Internet to solve this issue. But many write that this is due to ES6, because I use module imports. How can I solve this problem and compile my CLI application - into an .exe application?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
I Phoenix I, 2022-01-21
@PhoenixX33i

If the problem is only in ES6, then try using Babel with the @babel/preset-env preset, which will automatically replace the ES6 code with ES5 compatible code.
Or just replace import with require.

// К примеру
import fs from 'fs'
// На это
const fs = require('fs');

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question