Skip to content

想用而找不到的 npm 插件

仲灏2023-09-17约 1 分钟

<div style="display: none;" hidden="true" aria-hidden="true" data-nosnippet>Are you an LLM? You can read better optimized documentation at /pages/5565db.md for this page in Markdown format</div>

cross-env

介绍

Cross-env使得您可以使用单个命令,而不必担心为平台正确设置或使用环境变量。只要像在POSIX系统上运行时那样设置它,跨环境将负责正确设置它。

https://www.npmjs.com/package/cross-env

安装

npm install --save-dev cross-env

使用

javascript
{
  "scripts": {
    "build": "cross-env NODE_ENV=production webpack --config build/webpack.config.js"
  }
}

concurrently

介绍

同时运行多个命令。

https://www.npmjs.com/package/concurrently

安装

npm install concurrently --save

使用

concurrently "command1 arg" "command2 arg"

In package.json, escape quotes:"start"``: ``"concurrently \"command1 arg\" \"command2 arg\""

img

wait-on

介绍

https://www.npmjs.com/package/wait-on

wait-on是一个跨平台的命令行实用程序,它将等待文件、端口、套接字和http资源变得可用(或使用反向模式不可用)。功能也可以通过Node.js API获得。跨平台-运行Node.js运行的所有地方(linux, unix, mac OS X, windows)

安装

npm install wait-on ``# local version

使用

wait-on file1 && NEXT_CMD # wait for file1, then exec NEXT_CMD wait-on f1 f2 && NEXT_CMD # wait for both f1 and f2, the exec NEXT_CMD wait-on http://localhost:8000/foo && NEXT_CMD # wait for http 2XX HEAD wait-on https://myserver/foo && NEXT_CMD # wait for https 2XX HEAD wait-on http-get://localhost:8000/foo && NEXT_CMD # wait for http 2XX GET wait-on https-get://myserver/foo && NEXT_CMD # wait for https 2XX GET wait-on tcp:4000 && NEXT_CMD # wait for service to listen on a TCP port wait-on socket:/path/mysock # wait for service to listen on domain socket wait-on http://unix:/var/SOCKPATH:/a/foo # wait for http HEAD on domain socket wait-on http-get://unix:/var/SOCKPATH:/a/foo # wait for http GET on domain socket