繁难demo
- 编码 package.json
{
"name": "daytoy",
"version": "0.0.1",
"description": "nodejs cli program",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "daytoy",
"license": "ISC",
"bin": {
"toy": "index.js"
}
}
bin
属性具备可执行文件,cli
命令要求运行index.js
文件。
- 编写可执行文件
#! node
console.log('DAY DAY TOY !');
/**
在Linux和基于Unix的操作系统(例如Mac)中,#! / usr / bin / env node 不仅仅是一个正文。它应用在 /usr/bin/env 中注册的node命令来运行文件。
然而,在Windows中,这只是一个正文。
**/
- 运行
npm i -g
在package.json中装置配置
- 执行自定义的命令
问题: 零碎上禁止运行脚本?
解决:
1.关上PowerShell(以管理员身份运行)
2.set-ExecutionPolicy RemoteSigned //设置为关上
3.键入Y或者A,批准
4.执行get-executionpolicy查看是否更改胜利,为RemoteSigned示意胜利
### 利用:创立工程脚手架模板交互(nodejs)
发表回复