【问题标题】:how to run program when the start script is missing缺少启动脚本时如何运行程序
【发布时间】:2023-01-20 17:13:47
【问题描述】:

当我尝试使用 npm start 运行我的代码时出现此错误 -

npm 开始 -

错误!缺少脚本:“开始”

错误!

错误!你是说其中之一吗?

错误! npm star # 标记你最喜欢的包

错误! npm stars # 查看标记为收藏夹的包

错误! 错误!要查看脚本列表,请运行:

错误!运行

错误!可以在以下位置找到此运行的完整日志:

错误! C:\Users\Local\npm-cache_logs\2023-01-20T08_18_49_238Z-debug-0.log

【问题讨论】:

  • 你可能没有在你的package.json文件中定义start脚本,你可以从node your-script.js开始

标签: javascript node.js reactjs


【解决方案1】:

您好,您需要在 package.json 文件中定义启动脚本。例如在这个节点项目中 package.json(删除注释以使用 json):

{
  "name": "node-starter",
  "version": "0.0.0",
  "scripts": {
    "test": "echo "Error: no test specified" && exit 1",
    "start": "node index.js" // <-- start script here to start a node program
  }
}

完整示例 https://stackblitz.com/edit/node-g7ntls?file=index.js,package.json

【讨论】:

    【解决方案2】:

    你可以使用像 node entry.js

    【讨论】:

      猜你喜欢
      • 2021-03-30
      • 2020-06-30
      • 1970-01-01
      • 2019-04-13
      • 2017-05-21
      • 1970-01-01
      • 2014-11-16
      • 2019-05-16
      • 2018-09-10
      相关资源
      最近更新 更多