Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NODE_PATH not recognized

Tags:

node.js

Here is my package.json script:

"scripts": {
    "start": "NODE_PATH=$NODE_PATH:./shared node",
    "dev": "npm run start & webpack-dev-server --progress --color"
  },

When I run npm start in Windows 8 it shows the below error:

node_path is not recognized as a internal or external command, operable program or batch file

like image 769
Anil S Avatar asked Aug 11 '15 04:08

Anil S


1 Answers

I had the same problem when I wanted to set the environment variable in a browserify script:

"scripts": {
  "build:symlinked": "NODE_PATH=./node_modules browserify src/index.js > dist/build.js"
}

To be able to use linked node modules that are requiring peer-dependencies.

As mentioned above, you can try to set the environment variable manually or by script where it seems you have to use different commands depending on what command line tool you use.

For not having to do this every time, I found that npm package: cross-env.

By installing it and applying the script like this

"scripts": {
  "build:symlinked": "cross-env NODE_PATH=./node_modules browserify src/index.js > dist/build.js"
}

I was able to solve that problem. This is mainly useful, if you work in a team with mixed MAC/Linux and Windows users, so you don't have to to take care about applying the Environment variables in such scripts anymore.

like image 66
gwildu Avatar answered Nov 20 '22 17:11

gwildu