【问题标题】:NPM packages in process.envprocess.env 中的 NPM 包
【发布时间】:2018-05-04 07:45:32
【问题描述】:

所有这些包是如何安装到 process.env 中的,为什么我在 npm 脚本中没有看到 NODE_ENV 设置?

"start": "NODE_ENV=dev npm run build && npm run watch && npm run tslint"

我的 npm 脚本:

"scripts": {
    "start": "npm run build && npm run watch && npm run tslint",
    "build": "npm run build-ts",
    "serve": "nodemon dist/Server.js",
    "watch": "concurrently -k -p \"[{name}]\" -n \"TypeScript,Node\" -c \"yellow.bold,cyan.bold,green.bold\" \"npm run watch-ts\" \"npm run serve\"",
    "test": "mocha --compilers ts:ts-node/register",
    "build-ts": "tsc",
    "watch-ts": "tsc -w",
    "tslint": "tslint -c tslint.json -p tsconfig.json",
    "debug": "npm run build && npm run watch-debug",
    "serve-debug": "nodemon --inspect dist/Server.js",
    "watch-debug": "concurrently -k -p \"[{name}]\" -n \"TypeScript,Node\" -c \"yellow.bold,cyan.bold,green.bold\" \"npm run watch-ts\" \"npm run serve-debug\""
},

【问题讨论】:

  • npm install 可能吗?还有你的配置文件是什么样的?

标签: typescript npm typescript-typings npm-scripts


【解决方案1】:

所有这些包是如何进入 process.env 的

process.env 反映系统环境变量。例如。运行env。更多:https://nodejs.org/api/process.html#process_process_env

以及为什么我没有看到 NODE_ENV 设置

根据您的命令NODE_ENV=dev npm run build && npm run watch && npm run tslint,它不会以任何方式持久化到环境中,但会在npm run build 运行时出现。

【讨论】:

  • 感谢在不同脚本中移动设置环境变量的提示,它有帮助,请参阅上面的正确答案。
【解决方案2】:

设置环境变量的正确脚本在"serve": 这工作"serve": "NODE_ENV=development nodemon dist/Server.js",

【讨论】:

    猜你喜欢
    • 2021-12-23
    • 1970-01-01
    • 2020-08-20
    • 1970-01-01
    • 2021-06-05
    • 2019-02-23
    • 2013-11-03
    • 2020-12-16
    • 1970-01-01
    相关资源
    最近更新 更多