How to use environment variables to run node app in atom IDE - node.js

I have node project that contains .bat file to set all the env variables & then it run my server.js .
How can i achieve the same using IDE?
Currently when i am trying to run the code from atom ide its giving error for those environment variables not set as they are required to run my project.
While running from command prompt i can simply run the .bat file which sets all the environment variables required for my project followed by "node server.js" command to run my project.
But from atom IDE when i run server.js it is not able to find the environment variables. How can i define/set these environment variables so that the atom IDE can read it & use them when i run server.js.??

Install XAtom NodeJS Debugger: apm install xatom-debug-nodejs
Toolbar will be shown,
Choose your project,
click on Node.js button and in the popup shown configure your project setting and
environment variables.

Related

Adding Environment Variables to the node process using CMD

I am trying to add the environment variables to the node process on start using CMD. I want achieve this without using the script in package.json & not using the dotenv package
I'm going through one of the node.js lectures & found the below command which will set the environment variables to the node process as below :
NODE_ENV=development nodemon server.js
After some research I found that it is different for windows & as below :
SET NODE_ENV=development&&nodemon server.js
I tried the same in the cmd but got the error message NODE_ENV is not recognized as an internal or external command.
Just wanted to know how in CMD this adding environment variables works

PATH variables empty in electron?

I'm trying to access items in my PATH environment variable from my electron instance, when I run it with npm start while developing it through node.js I get all the expected variables, but when I run the electron application with my resources inside I'm left with only usr/bin
This is how it looks like when I run it from npm:
And this is how it looks when run from the electron mac application precompiled:
Does anyone know why this could be the case? And if I can do anything to reach my normal PATH variables
UPDATE:
After a lot of research I found out that GUI applications ran from finder or docker in Mac OSX use different environment variables compared to if they are ran from the terminal:
This can be edited through plist files, either globally or application specific
You can use fix-path package. Works perfectly!
const fixPath = require('fix-path');
console.log(process.env.PATH);
//=> '/usr/bin'
fixPath();
console.log(process.env.PATH);
//=> '/usr/local/bin:/usr/bin...'

Pass process.env variables to protractor cli

How can I pass in custom Node process.env variables on the protractor command line when I run my tests?
My protractor E2E tests using Angular work great from IntelliJ. In my IntelliJ Run/Debug configuration, I provide environment variables, such as USER_EMAIL, USER_PASSWORD, APP_URL and some others. I want to do this with the protractor cli so I can run these tests from terminal.
I can run tests from terminal only when I edit the protractor.conf.js file. I am not sure of how to specify the process.env variables on the command line. I do not want to edit protractor.conf.js as it is shared by many engineers.
Is there a way to pass in these process.env variables using the protractor cli?
This is the cli command I am running.
protractor protractor.conf.js --specs ./test/ui/my-tests/myspec.ts
use cross-env, you can set the environment variable in one command line together with actual command to execute, no need to export/set environment varaible ahead actual command. And cross-env is cross platform.
Example:
cross-env USER_EMAIL=abc#123.com APP_URL=http://abc.123.com protractor protractor.conf.js --specs ./test/ui/my-tests/myspec.ts

node 6.11.3 NODE_EXE not found in IntelliJ

I've updated my project to use node 6.11.3. When I now try to start a npm-script by using the Run-configurations provided from IntelliJ, I always receive the following error:
Error: Failed to replace env in config: ${NODE_EXE}
Important: This error appears only if I start npm from within my project. If I use the windows cmd, the error doesn't appear.
What could possibly have changed between node 6.11.2 and 6.11.3? Because with the prior version, everything worked fine.
A workaround for me is to add the NODE_EXE variable to my run configuration, but In my opinion, that shouldn't be needed, because it worked in 6.11.2 too.
Looks as if you have ${NODE_EXE} variable set in one of your npmrc files (see https://docs.npmjs.com/files/npmrc#files), and it can't be properly expanded for some reason when you run your script in the IDE.
is the issue specific to certain project?
how many npm versions do you have installed? Please check that npm chosen in Node.js Interpreters dialog is the same as you use in cmd shell?
please create an env.js file with console.log(process.env) and try running it via npm ("env" : "node env.js") in both cmd console and WebStorm - what is the result?

Why can't I run my node.js express web application

Node.js and the express generator are really handy and simple to understand. I cannot however get my server to start by running c:\my-application-root>DEBUG=my-application ./bin/www
Windows doesn’t seem to understand that command. I can however run it by calling node ./bin/www
Am i missing something?
Did you try set DEBUG=my-application followed by node ./bin/www? Windows does not allow setting an environment variable in the way that Linux and others do.
1st command 'set DEBUG=my-application'.2nd command 'npm start'
First you need to go the cmd that is supported by node (search for node cmd when you click in windows icon if you're using windows 7)
type
set DEBUG=my-application
Second
simply cd c:\my-application\bin\
Then type
node www
www is the file that contains the script needed by node to run your server, DEBUG if set as an environment variable will also help you run node against it since the path will be known

Resources