Bundled exe doesnt work without node_modules present in the same folder
See original GitHub issueHello. I’m currently trying to bundle a simple script to list keys/values in the windows registry. For this i use the NPM ‘regedit’, however it seems to fail when packaged with nexe and I’m unsure if it’s something I’m doing wrong or not since this is the first time I’m using Nexe.
The error it’s outputting is:
events.js:174
throw er; // Unhandled 'error' event
^
SyntaxError: Unexpected token I in JSON at position 0
at JSON.parse (<anonymous>)
at DestroyableTransform.module.exports.vbsOutputTransform [as _transform] (C:\snapshot\Registry Cleanup\node_modules\regedit\lib\helper.js:51:18)
at DestroyableTransform.Transform._read (C:\snapshot\Registry Cleanup\node_modules\through2\node_modules\readable-stream\lib\_stream_transform.js:184:10)
at DestroyableTransform.Transform._write (C:\snapshot\Registry Cleanup\node_modules\through2\node_modules\readable-stream\lib\_stream_transform.js:172:12)
at doWrite (C:\snapshot\Registry Cleanup\node_modules\through2\node_modules\readable-stream\lib\_stream_writable.js:237:10)
at writeOrBuffer (C:\snapshot\Registry Cleanup\node_modules\through2\node_modules\readable-stream\lib\_stream_writable.js:227:5)
at DestroyableTransform.Writable.write (C:\snapshot\Registry Cleanup\node_modules\through2\node_modules\readable-stream\lib\_stream_writable.js:194:11)
at StreamSlicer.ondata (_stream_readable.js:689:20)
at StreamSlicer.emit (events.js:189:13)
at addChunk (_stream_readable.js:284:12)
Emitted 'error' event at:
at DestroyableTransform.onerror (_stream_readable.js:713:12)
at DestroyableTransform.emit (events.js:189:13)
at onwriteError (C:\snapshot\Registry Cleanup\node_modules\through2\node_modules\readable-stream\lib\_stream_writable.js:250:10)
at onwrite (C:\snapshot\Registry Cleanup\node_modules\through2\node_modules\readable-stream\lib\_stream_writable.js:268:5)
at WritableState.onwrite (C:\snapshot\Registry Cleanup\node_modules\through2\node_modules\readable-stream\lib\_stream_writable.js:106:5)
at afterTransform (C:\snapshot\Registry Cleanup\node_modules\through2\node_modules\readable-stream\lib\_stream_transform.js:104:5)
at TransformState.afterTransform (C:\snapshot\Registry Cleanup\node_modules\through2\node_modules\readable-stream\lib\_stream_transform.js:79:12)
at DestroyableTransform.module.exports.vbsOutputTransform [as _transform] (C:\snapshot\Registry Cleanup\node_modules\regedit\lib\helper.js:53:10)
at DestroyableTransform.Transform._read (C:\snapshot\Registry Cleanup\node_modules\through2\node_modules\readable-stream\lib\_stream_transform.js:184:10)
at DestroyableTransform.Transform._write (C:\snapshot\Registry Cleanup\node_modules\through2\node_modules\readable-stream\lib\_stream_transform.js:172:12)
What you expected to happen: After bundling main.js, running the bundles exe file should list the values and keys at the given registry path.
How to reproduce it (as minimally and precisely as possible):
nexe main.js --build
main.js:
const regedit = require('regedit')
regedit.list("HKCU\\Software\\Microsoft\\Windows NT\\CurrentVersion\\Devices")
.on('data', function(entry) {
const values = entry.data.values;
console.log('Values found: ', values)
})
.on('finish', function() {
console.log('finished')
})
Anything else we need to know?: The .exe file works if node_modules with regedit installed is present in the same folder as the .exe file.
Environment
- Platform(OS/Version): Windows 10 build 1803
- Host Node Version: v11.11.0
- Target Node Version: v11.11.0
- Nexe version: v3.2.1
- Python Version: v2.7.15
Issue Analytics
- State:
- Created 4 years ago
- Comments:18 (4 by maintainers)
Top Results From Across the Web
What could cause an error related to npm not being able to ...
Open command prompt , go to path angular folder and run Yarn. Run angular\nswag\refresh.bat. Run npm start from the angular folder.
Read more >Bundle your Node app to a single executable for Windows ...
Run pkg . from your app directory to build an executable. ... app.exe as a standalone compiler that does not require Node or...
Read more >Bundling Extensions - Visual Studio Code
Bundling Extensions. The first reason to bundle your Visual Studio Code extension is to make sure it works for everyone using VS Code...
Read more >Tutorial: Create a Node.js and React app in Visual Studio
Visual Studio adds the dist folder, which contains app-bundle.js and app-bundle.js.map, to the project. Open app-bundle.js to see the transpiled ...
Read more >folders - npm Docs
When in local mode, executables are linked into ./node_modules/.bin so that they can be made available to scripts run through npm. (For example,...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Are there packages in particular that are failing to load?
One could use ncc to provide a bundle to nexe. Any other dist artifacts produced there (eg native modules) will have to be shipped alongside the binary)
I had the same issue and finally realized it was because I’ve used a child process with more required modules inside that JS file.