This solution is outdated. Check out kentcdodds/cross-env which might better suit your needs!
Better NPM scripts runner
From this:
{
"scripts": {
"build:dist": "NODE_ENV=development webpack --config $npm_package_webpack --progress --colors",
"test": "NODE_ENV=production karma start"
}
}
To this:
{
"devDependencies": {
"better-npm-run": "~0.0.1"
},
"scripts": {
"build:dist": "better-npm-run build:dist",
"build:prod": "better-npm-run build:prod",
"test": "better-npm-run test"
},
"betterScripts": {
"build:dist": "webpack --config $npm_package_webpack --progress --colors",
"build:prod": {
"command": "webpack --config $npm_package_webpack --progress --colors",
"env": {
"NODE_ENV": "production"
}
},
"test": {
"command": "karma start",
"env": {
"NODE_ENV": "test"
}
}
}
}
The betterScripts
script definition can either be a string or sub-object with command
and env
attributes. Values defined in the env
block will override previously set environment variables.
Note that depending on the OS and terminal you're using, dots, spaces or other special characters in the command path may be treated as separators and the command will be parsed wrong.
{
"serve:dist": "./node_modules/.bin/webpack-dev-server --hot --inline --config webpack/development.js"
}
To prevent this you need to explicitly wrap the command path with double quotes:
{
"serve:dist": "\"./node_modules/.bin/webpack-dev-server\" --hot --inline --config webpack/development.js"
}
If you have an .env
file in your project root it will be loaded on every command.
NODE_PATH=./:./lib
NODE_ENV=development
PORT=5000
Environment variables defined in the betterScripts
script definition will take precedence over .env
values.
Currently, using bash variables (PWD, USER, etc.) is not possible:
"command": "forever start -l ${PWD}/logs/forever.log -o ${PWD}/logs/out.log -e ${PWD}/logs/errors.log -a index.js",
In order to use them, you can create an script file (.sh
) instead:
forever.sh
:
forever start -l ${PWD}/logs/forever.log -o ${PWD}/logs/out.log -e ${PWD}/logs/errors.log -a index.js
package.json
:
"command": "./forever.sh"
This module expose 2 cli commands:
better-npm-run
and,bnr
which is an alias to the former.The shorter one is useful for cases where you have a script that calls several better-npm-run
scripts. e.g:
using the normal cli name
"scripts": {
"dev": "shell-exec 'better-npm-run install-hooks' 'better-npm-run watch-client' 'better-npm-run start-dev' 'better-npm-run start-dev-api' 'better-npm-run start-dev-worker' 'better-npm-run start-dev-socket'",
}
using the shorter alias
"scripts": {
"dev": "shell-exec 'bnr install-hooks' 'bnr watch-client' 'bnr start-dev' 'bnr start-dev-api' 'bnr start-dev-worker' 'bnr start-dev-socket'",
}
And for silence output, you can use -s
or verbose --silence
flags
bnr -s watch-client
And you can use -p
or verbose --path
to specify a custom path of dotenv file
bnr --path=/custom/path/to/your/env/vars start-dev
Also use -e
or verbose --encoding
to specify the encoding of dotenv file
bnr --encoding=base64 start-dev
See envdot docs for more infomation
通过查阅资料, 最终从以下几个方面解决了, 其实基本上可以确认因为tui-editor插件版本的问题 1. node 版本搞低点, 我现在用16.18.1 2. 从git拉取vue-element-admin项目 3. vscode 打开该项目, 注意根目录是项目根目录, 不要从项目根目录上一级打开, 然后vscode终端根目录运行以下代码 rm -rf node_modules rm packa
npm run serve 和 npm run dev 的区别 在我们运行一些 vue 项目的时候,输入npm run serve或者 npm run dev的其中一个时,系统会报错: PS C:\Users\LENOVO\Desktop> npm run dev npm ERR! missing script: dev npm ERR! A complete log of this run c
昨天在写一个移动端的横向滚动,引入cube-ui的cube-scroll,硬是不出来效果,后来还是自己的css有问题。要想引入得经过以下几个步骤: 一、安装cube-ui npm install cube-ui --save 修改 package.json 并安装依赖: ... "scripts": { "dev": "webpack-dev-server --inline
临时起意,想编译下1.14的源码,结果在flink-runtime-web module下报错,导致编译失败。错误如下: npm ci --cache-max=0 --no-save 解决办法: 进入flink-runtime-web的web-dashboard目录下,执行命令: npm install 返回上一级目录,将pom文件中 <arguments>ci --cache-max=0 -
npm 更新 npm By Carl-Johan Kihl 卡尔·约翰·基尔(Carl-Johan Kihl) After using NPM for almost 8 years, I’ve learned things along the way that I wish I knew when I started. Let’s call them tricks, things that dra
本文翻译自:Sending command line arguments to npm script The scripts portion of my package.json currently looks like this: 我的package.json的scripts部分当前如下所示: "scripts": { "start": "node ./script.js server"
网页数据加载多了都会出现卡顿,手机端的列表一般都是无限加载的,加载的数据量大了我们就需要特殊处理下了,vue-better-list-view 这个组件就是为了解决这个问题。 使用 提供 npm 版本和 umd 版本 npm 安装 // install npm i vue-better-list-view --save-dev // in your project import listView
npm 安装 npm install -g create-react-app 时报错 报错信息: 0 info it worked if it ends with ok 1 verbose cli [ 'D:\\path\\nodejs\\node.exe', 1 verbose cli 'D:\\path\\nodejs\\node_modules\\npm\\bin\\npm-cli.js
zsh-better-npm-completion Better completion for npm Makes npm install recommendations from npm cache Makes npm uninstall recommendations from dependencies/devDependencies Shows detailed information on
npm-run Run executables in node_modules from the command-line Use npm-run to ensure you're using the same version of a package on the command-line and in package.json scripts. Any executable available
index npm-run-all run-s run-p Node API npm-run-all A CLI tool to run multiple npm-scripts in parallel or sequential. ⤴️ Motivation Simplify. The official npm run-script command cannot run multiple scr
看不懂。。。 log日志如下
问题内容: 和之间有什么区别? 我在项目中注意到,有时npm在执行时会开始失败,但是在运行时,它可以正常工作。 如何这两个目标的内部运作,即与不同? 问题答案: 将依赖项安装到您正在处理的节点项目的目录中。您可以调用另一个node.js项目(模块),以将其安装为项目的依赖项。 是的别名,除非您在package.json文件中指定“ build”的作用,否则它什么都不做。它使您可以在将其用于另一个项
better-sqlite3 The fastest and simplest library for SQLite3 in Node.js. Full transaction support High performance, efficiency, and safety Easy-to-use synchronous API (better concurrency than an asynch