Comments (3)
I was unable to get it working with node 18 or 20.
After several days of frustration I managed to get it working with the latest git commit, and I assumed that was the issue. I thought I had solved it...
However, after cleaning out my dev environment (which is docker based) and starting clean from the latest commit, it failed :( I was unable to figure out what I did before that fixed it...
I ended up finding a fork of the pkg project which supports the latest node release.
from nexe.
I was having the same issue as described above and found out that nexe does include the code in the executable but still looks for the files in the working directory. I'm working in node 18.19.0, nexe installed via npm [email protected]
@calebboyd Since you added the "more inforation needed" tag, I'll add some examples:
Single file
index.js (D:\src)
console.log("Hello World!");
nexe . -i index.js -o test.exe
results in test.exe
If we run test.exe in D:\src, we get the following:
Hello World!
and all is good.
However if we move the test.exe to a different folder (in this case D:\test) and run test.exe, we get the following:
node:internal/modules/cjs/loader:1137
throw err;
^
Error: Cannot find module 'D:\test\index.js'
at Module._resolveFilename (node:internal/modules/cjs/loader:1134:15)
at Module._load (node:internal/modules/cjs/loader:975:27)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:128:12)
at node:internal/main/run_main_module:28:49 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
Node.js v18.19.0
But if we add an empty index.js file next to the test.exe, we once again have our Hello World!
.
Multiple files
Image we have multiple files:
D:/src/index.js
const controller = require("./controllers/controller");
controller.foo();
D:/src/controllers/controller.js
function foo(){console.log("bar");}
module.exports = { foo }
- Creating the exe will work as long as it remains in the same folder as the original code.
- Once we move the exe, it will break, asking for the original files (but in the new folder, respecting the relative paths in the require so
require("controllers/controller.js")
inD:\test
will go looking forD:\test\controllers\controller.js
. - Creating the exact same folder structure but with empty files will restore the exe
In my larger project where I'm using typescript, then run nexe in the dist folder containing the regular js files, I have also found that the modules I've created and import using require("./foo/bar"), are usually not included in the project. But if I specifically include them using nexe . -r "**/*"
, they will be included and the exe does run when moved if the empty files are once again added to the test folder.
npm packages
- If you
require
and npm installed packages, then copy your node_modules folder next to the moved executable, it will be fixed. - I didn't test out my theory using any npm installed modules and clearing their content but I assume if you were to copy the node_modules folder then cleared all files and left them empty, the moved executable will work again
Conclusion
The code is included (even though you might have to include them using the -r
) but the executable will still go looking for the files even though it doesn't care about what the content of those files might be.
from nexe.
Related Issues (20)
- Promise not resolving HOT 1
- How to exclude files and folder from being included in a nexe build?!
- vcbuild.bat nosign release x64 exited with code: 1 HOT 3
- Using NEXE with NodeJS v20? HOT 2
- Project Status HOT 1
- Meet 'ReferenceError: file is not defined' after build from source HOT 2
- node exe is unable find sqlite3 HOT 1
- Are monorepos supported? HOT 1
- _third_party_main: this is not a typed array HOT 1
- sqlite3 errors
- Node CLI options are not disabled for node 20.11 HOT 1
- Error: vcbuild.bat nosign release x64 exited with code: 1 HOT 1
- Nexe eats up any command line parameter starting with -- like --help HOT 3
- Confused Usage - Help About Node 18 Versions HOT 3
- Build flag with windows-x64-20.11.1 produces 16bit results ? HOT 1
- Feature Request: Replace download dependency with node-downloader-helper or something similar to resolve CVE-2022-33987
- I got `Error: spawn EINVAL` error, after change host's node version `21.7.2` to `21.7.3` or `20.12.1` to `20.12.2` on Windows. HOT 9
- node_modules unclear behaviour
- Instructions for general usage are unclear HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nexe.