How to add multiple NODE_PATH in package.json?

十年热恋 提交于 2019-12-05 03:43:53

The way you are using NODE_PATH in your example, by setting it twice, you are overwriting the writing the value you assign first with the second time.

Instead, set NODE_PATH to multiple paths, delimited by colons (on MacOS or Linux) or semicolons (Windows), like this:

{
    "name": "my-app",
    "description": "env",
    "repository": "https://github.com/xxx.git",
    "scripts": {
        "dev": "NODE_PATH=./lib:./ node server.js",
        "start": "cross-env NODE_ENV=production NODE_PATH=./:./modules/ nodemon --exec babel-node --presets es2015 server.js"
    },
    "dependencies": {
        "cross-env": "^5.0.5",
       "express": "^4.15.4"
    },
    "license": "MIT"
}

See Node.js documentation:

https://nodejs.org/api/modules.html#modules_loading_from_the_global_folders

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!