关于npm:npm-自定义全局命令

8次阅读

共计 247 个字符,预计需要花费 1 分钟才能阅读完成。

npm 自定义全局命令
装置 node 全局命令

一、创立 package.json 文件,创立命令为 hello

{
  "name": "demo",
  "version": "1.0.0",
  "dependencies": { },
  "bin": {"hello": "./index.js"}
}

二、设置文件运行的后果 index.js

#!/usr/bin/env node
console.log('hello world')

三、在全局装置(要 package.json 根目录下装置),装置本地的包 到

npm i . -g

四、运行全局命令

hello
正文完
 0