gpt4 book ai didi

node.js - 在 Node 项目上运行 make 命令

转载 作者:行者123 更新时间:2023-12-03 09:12:51 24 4
gpt4 key购买 nike

我有一个 makefile,比方说;

foo2:
echo foo2

foo: prefoo
echo foo


foobar: prefoobar
echo foobar

all: foo foo2 foobar

所以我需要在 Node 项目上运行这个 makefile 命令。我需要通过使用我的 package.json 文件运行 make foomake foo2 。我怎样才能做到这一点?我可以写在下面吗?

"scripts": { "foo": "make foo", "foo2": "make foo2" }

谢谢

最佳答案

So I need to run this makefile command on node project. I need run make foo or make foo2 via using my package.json file. how can I do that? can I write it below ?

"scripts": { "foo": "make foo", "foo2": "make foo2" }

你可以,而且它会按照你想要的方式工作。事实上,npm docs包含在 npm 中运行 Make 的示例脚本:

If you want to run a make command, you can do so. This works just fine:

{ "scripts" :
{ "preinstall" : "./configure"
, "install" : "make && make install"
, "test" : "make test"
}
}

需要记住的一件事是 npm并以不同的方式管理依赖关系:

  • npm不会自动在 Makefile 中查找生命周期依赖项:您必须定义 { "prefoo": "make prefoo" }如果您打算prefoofoo之前运行通过npm ;

  • Make 没有隐含的运行方法 npm脚本,所以如果你想让 Make 运行你需要添加类似的东西 npm对于它的一些目标:

    prefoo:
    npm run prefoo

关于node.js - 在 Node 项目上运行 make 命令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40383129/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com