In my Electron app in Windows (which I believe uses node.js or io.js under the hood?), I've got the following line of code which is problematic:
var ipconfigOutput = child_process.execSync("ipconfig").toString();
This code works without issue when I run the app via command line, e.g. electron ..
However, I'm running into a problem after packaging my application. When I build the app using electron-packager, this code works just fine if I invoke the built exe file from the command line. However, if I run the program by double-clicking the built exe within Windows Explorer, I get the following error:
Error: EPERM: operation not permitted, write
Why is this error occurring, and how should I change the above code?
I imagine it is due to a difference in how stdout works when a process is started via the command line vs. when it is started via Explorer, but I don't understand IO well enough to know what is going wrong here.
I discovered that I can get the code to work by changing it to
var ipconfigOutput = child_process.spawnSync("ipconfig").stdout.toString();
However, I am not sure why spawnSync works now and execSync did not. If anyone could comment, that'd be great!
Related
For context I am working in windows 10 with Node.js.
Having set up cypress successfully after a load of trial and error in one project file I am starting from scratch with another project file to work out the exact steps.
For some reason it is failing with the new attempt and having noticed the errors show v 7/3/0 whereas the errors for the previous showed v 7.2.0 I thought I'd return to the first project file and try
cypress clear cache as recommended at docs.cypress.io/guides/references/troubleshooting which I've assumed that was to be run at the Node.js command prompt.
Having done so Node.js is just hanging.
Is this expected behaviour?
Have I misunderstood the instructions?
Thanks
I'm trying to simply create a React Native project via Webstorm but I get this error upon trying to do so which's resulting in myself not being able to start a project.
Whenever I do choose a Node interpreter it gives me an error that says Unspecified react-native cli package at the same spot that says Please specify node.js interpreter correctly.
I've been starting React Native projects like this since the beginning but this time I get this error out of no where, I don't know where it came from. How can I fix this?
Opens up your terminal, and use the which command to find our your NodeJS interpreter
$ which node
/Users/felixfong/.nvm/versions/node/v8.0.0/bin/node
And copy that result, and update your Node interpreter field inside yoru WebStorm
Hopes this help
This few lines node app runs into error when I execute directly from ms vs code. However, when I use nodemon it runs without error. node -v and npm -v tells me all is well. nodemon being successful also suggests that all is well. However node app.js from cmd runs into same error. I suspect the Path info but this seem to be correct as well; at least to the best of my knowledge.
See screen capture below.
Folks you help/suggestions are welcome.
Thanks in advance.
I'm playing around with the Cordova hooks capabilities and I'm trying to test using a node application as a hook. In this article: http://devgirl.org/2013/11/12/three-hooks-your-cordovaphonegap-project-needs/ it references running node applications, so I know it's possible.
I've created a simple node application that I'm using to test the before prepare and after prepare process:
#! /usr/bin/env node
console.log("this is a node module");
When I run my prepare, I get the following error:
C:\Users\jwargo\dev\lunchmenu>cordova prepare
The system cannot find the path specified.
Hook failed with error code 1: C:\Users\jwargo\dev\lunchmenu\hooks\before_prepare\test.js
I can't find any information anywhere about what an error code of 1 means here.
I've tested the node code and it runs fine with "node test.js" and when I execute test.js from the command line Windows simply launches my default editor.
So, can anyone tell me what I'm doing wrong or what I need to do to be able to execute a node application as a hook with the Cordova CLI?
Figured it out with some help from the Cordova dev team. The space in my shebang was causing the problem. I removed it and the problem went away.
I'm trying to get node.js to run a sample script I've created. I'm using Windows. mysamplescript.js is in the same folder as the node.js executable. When I type in
node mysamplescript.js
I get ... returned on the next line. The docs for node aren't exactly stellar. Am I missing something?