I'm trying to build a executable of Node.js using pkg-npm
But it doesn't find/add the index.html that I send to node. After compile and executed the index-win.exe that was generated I get this message:
\nodejs_exec\index.html' was not included into executable at compilation stage. Please recompile adding it as asset or script...
I already tried to add the file in the package.json like this:
"pkg":{
"scripts": [],
"assets": [
"index.html"
],
"targets": [
"node14-win-x64"
]
},
My node folder is like this:
node_exec
│ index.js
│ package.json
│ index.html
| node_modules
And this is my index.js:
const express = require('express');
const app = express();
const PORT = process.env.PORT || 4000;
const open = require('open');
const path = require('path');
app.get('/', (req, res)=>{
res.sendFile(__dirname + '/index.html');
});
app.listen(PORT, ()=>{ console.log(`Listening on port ${PORT}`)})
And the command that I used to create the .exe is:
pkg index.js