[英]node.js production settings
我在用於Windows的node.js中制作了一個小應用,
我遵循了一些指南和技巧,並下載了“ config”和“ cross-env”軟件包。
我將此部分添加到我的package.json-
"scripts": {
"start": "cross-env SET NODE_ENV=development& nodemon server.js",
"qa": "cross-env SET NODE_ENV=qa& nodemon server.js",
"prod": "cross-env SET NODE_ENV=production& nodemon server.js"
}
我還在配置文件夾default.json,production.json和qa.json下添加了3個json文件。
我計划使用config軟件包的示例是:
var config = require('config');
var connectionString = config.get('connectionString');
現在,我掃描了很多有關解決方案的帖子,但是到目前為止,當我嘗試運行"npm prod"
或"npm qa"
時,似乎無濟於事,我收到以下消息:
F:\MeanApp>npm prod
Usage: npm <command>
where <command> is one of:
access, adduser, bin, bugs, c, cache, completion, config,
ddp, dedupe, deprecate, dist-tag, docs, doctor, edit,
explore, get, help, help-search, i, init, install,
install-test, it, link, list, ln, login, logout, ls,
outdated, owner, pack, ping, prefix, profile, prune,
publish, rb, rebuild, repo, restart, root, run, run-script,
s, se, search, set, shrinkwrap, star, stars, start, stop, t,
team, test, token, tst, un, uninstall, unpublish, unstar,
up, update, v, version, view, whoami
npm <command> -h quick help on <command>
npm -l display full usage info
npm help <term> search for help on <term>
npm help npm involved overview
Specify configs in the ini-formatted file:
C:\Users\me\.npmrc
or on the command line via: npm <command> --key value
Config info can be viewed via: npm help config
npm@5.5.1 E:\Program Files\nodejs\node_modules\npm
到目前為止,我未能弄清問題的根源。
當錯誤消息試圖告訴您時,npm沒有這樣的命令。 自定義scripts
不會直接成為npm命令。
而是使用npm run運行腳本。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.