Node / React app, packaging for Linux with pkg - node.js

I'm trying to package a node / react app as a native executable for each of Mac / Windows / Linux, using the node package 'pkg' (https://github.com/zeit/pkg/).
I can run the application with node on my machine without issue. I was also successfully able to use pkg to build and run the Mac version, and it works as expected. With the Linux version, the pkg build works (ie no errors), but I am getting an error when running the executable.
Error spawn /snapshot/IXmapsClient/node_modules/open/xdg-open ENOENT
(more detailed version below)
My understanding is that snapshot is the 'internal' directory created by pkg. The node module dir and file exists at ~/Dev/IXmaps/IXmapsClient/node_modules/open/ and has the correct permissions (along with all other required node_modules used by this application).
Details of what I'm working with:
Ubuntu 18.04 (I'm working on a Virtualbox VM with OSX underneath, in the event that that is relevant)
Node 10
Pkg 4.4.2 (pkg -t node10-linux-x64 server.js -o dist/linux/IXmapsClient --config package.json)
Full error message:
events.js:174
throw er; // Unhandled 'error' event
^
Error: spawn /snapshot/IXmapsClient/node_modules/open/xdg-open ENOENT
at Process.ChildProcess._handle.onexit (internal/child_process.js:240:19)
at onErrorNT (internal/child_process.js:415:16)
at process._tickCallback (internal/process/next_tick.js:63:19)
at Function.Module.runMain (pkg/prelude/bootstrap.js:1317:13)
at startup (internal/bootstrap/node.js:320:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:659:3)
Emitted 'error' event at:
at Process.ChildProcess._handle.onexit (internal/child_process.js:246:12)
at onErrorNT (internal/child_process.js:415:16)
[... lines matching original stack trace ...]
at bootstrapNodeJSCore (internal/bootstrap/node.js:659:3)

If anyone else encounters this issue, it looks to have been resolved. The author of the 'pkg' module has added support for the 'open' module with this commit: https://github.com/zeit/pkg/commit/db8487acd2d40af7b0cb1e63e133a707f93d725f

Related

graphicsmagic not installed in google cloud functions?

i m working in a project in firebase that uses graphics magic to convert images to pdf
it's working fine in local emulator
but doesnt in production
Error: Could not execute GraphicsMagick/ImageMagick: gm "convert" "./0" "./a4.pdf" this most likely means the gm/convert binaries can't be found at ChildProcess. (/workspace/node_modules/gm/lib/command.js:232:12) at ChildProcess.emit (events.js:198:13) at ChildProcess.EventEmitter.emit (domain.js:448:20) at Process.ChildProcess._handle.onexit (internal/child_process.js:246:12) at onErrorNT (internal/child_process.js:415:16) at process._tickCallback (internal/process/next_tick.js:63:19)
knowing that in the cloud functions documentation they said that graphics magic is included in the environement
see : https://cloud.google.com/functions/docs/tutorials/imagemagick
Edit : gm requires installation (apt get install), i can't do that in cloud functions , cuz i dont have access to the machine.
i'm working now with pdfkit, its does the same job and doesnt require installation (requires npm install tho)
You are supposed to include gm on your dependencies. You can do so by running:
npm install gm
And have your dependencies look like:
"dependencies": {
"#google-cloud/storage": "^5.0.0",
"#google-cloud/vision": "^2.0.0",
"gm": "^1.23.1"
}
I just followed this documentation and it's working fine on Nodejs10 runtime.
UPDATE: It looks like there's an open issue on GitHub about this problem. I suggest you put a comment in there and provide detailed information similar to what the reporter did.

karma-init fails on Windows 10 with Node.js 7.1.0 x64

After installing succesfully the following node packages:
karma
karma-jasmine
karma-chrome-launcher
jasmine-core
I get the following error when executing karma-init:
C:\Projects\SocialMeal>karma init
events.js:160
throw er; // Unhandled 'error' event
^
Error: write EINVAL
at exports._errnoException (util.js:1022:11)
at WriteStream.Socket._writeGeneric (net.js:715:26)
at WriteStream.Socket._write (net.js:734:8)
at doWrite (_stream_writable.js:334:12)
at writeOrBuffer (_stream_writable.js:320:5)
at WriteStream.Writable.write (_stream_writable.js:247:11)
at WriteStream.Socket.write (net.js:661:40)
at Interface._writeToOutput (readline.js:256:17)
at Interface._insertString (readline.js:406:12)
at Interface._ttyWrite (readline.js:933:18)
at Interface.write (readline.js:352:24)
Any clues?
After some time I found it.
It seems like an Node.js 7.1.0 issue. It happens with newer Node.js versions (<7.0.0) as posted here:
https://github.com/nodejs/node/issues/9542
Until they fix this issue you need to uninstall your node.js and install an older version (e.g.: 6.9.1) in order to make ir work.

Can't run nightmare script after switching pc

I have a script using nightmare and which works on my pc ,and couldnt get it working on another pc.
This is the error im getting :
Error: spawn D:\Projects\Lounge\Lounge\node_modules\electron-prebuilt\dist\elect ron.exe ENOENT
at exports._errnoException (util.js:874:11)
at Process.ChildProcess._handle.onexit (internal/child_process.js:178:32)
at onErrorNT (internal/child_process.js:344:16)
at doNTCallback2 (node.js:439:9)
at process._tickCallback (node.js:353:17)
at Function.Module.runMain (module.js:469:11)
at startup (node.js:134:18)
at node.js:961:3
It seems like its searching for the electron on my pc's path , how could i change it? I have the electron exec , in the node moudle , but the path is diffrent (F:\Lounge\Lounge\node_modules\electron-prebuilt\dist\electron.exe)
I have found out why it didn't work.
Nightmare has a native dependency which is installed on the user's home folder.
When i moved the project, i copied only the node_modules folder, and nightmare couldn't find the reconfigured binary path.
In order to solve this, i reinstalled nightmare using npm: npm install nightmare, or even better, i created a package.json file and stated my dependecies on it, and when i moved over the project (without node_modules), i reinstalled the dependencies using npm install.
Looks like you are running the script from D:\Projects\Lounge\Lounge. Try changing directory to F:\Lounge\Lounge and run the script.

Node.js appends command to current working directory and throws an error

I just installed Node.js on my Windows 7 machine, added it to the PATH and tried to use it. npm works perfectly (at least for now) and node --version prints v4.1.2.
However, when I try to execute another command like node update it appends the command to the current working directory and, of course, fails :
$ node help
module.js:338
throw err;
^
Error: Cannot find module 'c:\path\to\working\directory\help'
at Function.Module._resolveFilename (module.js:336:15)
at Function.Module._load (module.js:286:25)
at Function.Module.runMain (module.js:475:10)
at startup (node.js:118:18)
at node.js:952:3
What can I do?

Get 'spawn cmd ENOENT' when try to build Cordova application (event.js:85)

Get this error in windows cmd when I try to build (emulate) Cordova app.
D:\dev\Cordova\toDoList>cordova build android
Running command: D:\dev\Cordova\toDoList\platforms\android\cordova\build.bat
events.js:85
throw er; // Unhandled 'error' event
^
Error: spawn cmd ENOENT
at exports._errnoException (util.js:746:11)
at Process.ChildProcess._handle.onexit (child_process.js:1046:32)
at child_process.js:1137:20
at process._tickCallback (node.js:355:11)
ERROR building one of the platforms: Error: D:\dev\Cordova\toDoList\platforms\android\cordova\build.bat: Command failed with exit code 1
You may not have the required environment or OS to build this project
I checked system variables one more time and found the cause of the problem:
missing C:\Windows\System32\ variable.
I added it and that solved my problem
Hope, it help you too.
just add it to the PATH: C:\Windows\System32 and start cmd as Administrator
Goto > Control Panel\System and Security\System\Advance system setting\Enviroment variable and set system variables path C:\Windows\System32\ variable and restart your System.
I know this is old but I simply had to run Visual Studio 2015 as an administrator and it worked on Windows 7.
I know its too late to answer, but incase if someone ran into trouble again.
I tried the solutions above which tells to add System32 path, But in my case the cordova path was deleted by an accident.
So I added C:\Users\Aquib\AppData\Roaming\npm\node_modules\cordova\bin to environment variable path and it worked !

Resources