V
V
Vadim2015-11-17 15:07:25
Node.js
Vadim, 2015-11-17 15:07:25

How to set NODE_PATH via npm scripts?

Updated node to version 5. In package.json I write the following.

{
  "name": "app",
  "version": "1.0.0",
  "scripts": {
    "prestart": "set NODE_PATH=./server/config | echo %NODE_PATH%"
  },
  "dependencies": {
    "body-parser": "latest",
    "cookie-parser": "latest",
    "express": "latest",
    "express-session": "latest",
    "morgan": "latest"
  }
}

echo works, but shows that set did not work and therefore you cannot connect your module simply by name, which is in ./server/config. Maybe this is a bug in the new version or something special needs to be done?
Output of npm start >
C:\nodeTest>

> app@1.0.0 prestart C:\nodeTest
> set NODE_PATH=./server/config | echo %NODE_PATH%

%NODE_PATH%

> app@1.0.0 start C:\nodeTest
> node server.js

module.js:339
    throw err;
    ^
................

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
sim3x, 2015-11-17
@sim3x

Run from a bat script if you don't want to switch to a normal OS

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question