为什么“ npm开始”没有“运行”的工作,但没有其他脚本可以吗?

发布于 2025-01-28 09:42:42 字数 403 浏览 4 评论 0原文

在我的package.json文件中,有我的“ start”脚本的“脚本”部分。当我键入npm start时,它将运行“ start”脚本。但是,对于任何其他脚本,您必须通过执行npm运行[脚本名称]来运行它。

这使我有2个问题:

  1. 为什么“启动”脚本在不进行npm运行start start的情况下工作,但是没有其他脚本没有“运行”?
  2. 有什么方法可以使其他脚本在不进行NPM运行[脚本名称]的情况下运行?
    • 使用npm,答案是否。
      但是,如果您查看评论,可以说您可以使用YARN来执行此操作。

In my package.json file, there is the "scripts" section with my "start" script. When I type npm start it runs the "start" script. But for any other script, you have to run it by doing npm run [script-name].

This makes me have 2 questions:

  1. Why does the "start" script work without doing npm run start, but no other scripts work without "run"?
  2. Is there any way to make other scripts run without doing npm run [script-name]?
    • With NPM, the answer is no.
      But if you look at the comment, it is said that you can use yarn to do this.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

笑着哭最痛 2025-02-04 09:42:42

那是惯例。不,如果没有运行,您将无法运行其他脚本。

That's by convention. No, you cannot run other scripts without run.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文