M
M
mishapsv2015-08-16 15:30:37
Node.js
mishapsv, 2015-08-16 15:30:37

How to set environment variables (NODE_PATH)?

I constantly encounter the NODE_PATH problem.
For example, package.json says

"scripts": {
    "start": "NODE_PATH=$NODE_PATH:./shared node --harmony .",
    "dev": "npm run start & webpack-dev-server --progress --color",
    "build": "NODE_ENV=production webpack --progress --color -p --config webpack.prod.config.js"
  },

The assembly stumbles on NODE_PATH
"NODE_PATH is not an internal or external command executable by the program ..."
As I understand it, the problem is that the assembly was written on UNIX systems, and I have Windows.
It is necessary to set environment variables
Like set
d289a86d2bcf496597fe2966ce0a2395.jpg
But does not help.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
K
Konstantin Kitmanov, 2015-08-16
@mishapsv

Each value in scripts is, in fact, an operating system script. That's right, they were written for *nix, and under Windows they will not work even with all environment variables, because the type construction is NODE_PATH=$NODE_PATH:./sharednot valid for the Windows command line interpreter. You need to fix it to something like this SET NODE_PATH=%NODE_PATH%;.\shared: Most likely, the path to the shared folder should be absolute.
The build command should be changed to something like this:

cmd /C "set NODE_ENV=production && webpack --progress --color -p --config webpack.prod.config.js"

Other ways:
1) fork, write cross-platform scripts in JS that run the right things with the right parameters, put them in the project's bin folder and send a pull-request
2) change your mind and switch to Linux.
PS Now for cross-platform launch with the necessary environment variables there is set-env (not to be confused with setenv).

V
Vladimir Krasnoselskikh, 2015-08-16
@karavaiker

Try on command line (as admin)
npm install node-static

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question