node.js - 运行 Node.js 项目的惯用方式是什么
问题描述
运行具有 package.json 和 '"main": "index.js"' 的 Node.js 项目的惯用方法是什么?我要运行“node run”或“npm run”之类的东西吗?
package.json
文件:
{
"name": "bandymas",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC"
}
并且 index.js 文件存在。那么惯用的方法是什么?
解决方案
您可以将start
脚本添加到您的package.json
:
{
"name": "bandymas",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node index.js"
},
"keywords": [],
"author": "",
"license": "ISC"
}
这样,您只需运行npm start
.
推荐阅读
- c# - 重定向功能的异常行为
- php - 带有国家代码的手机号码的正则表达式
- flutter - Flutter Painter 在通过 360 度时绘制带有指示的圆弧
- python - 准确的体位检测
- acumatica - 无法在案例中启用自定义字段
- python - 弃用警告:remove_friend 已弃用。等待 coro(*args, **kwargs)
- android - Android 辅助功能 Chrome 读取 URL 缺少 http 或 https
- r - 如何组合多个向量,使每个向量的元素尽可能均匀分布?
- canvas - 如何将 WebXR 'immersive-xr' HMD 视图镜像/克隆到浏览器
- python - 在模板上使用 for 循环时不会显示来自 Listview 的对象 - Django