【问题标题】:Is it necessary to keep Node modules and Grunt file in same directory?是否有必要将 Node 模块和 Grunt 文件保存在同一目录中?
【发布时间】:2016-06-26 13:56:06
【问题描述】:

我是 Grunt 的新手,我正在做一个需要两个 Angular 应用程序的项目,但我想将节点模块和凉亭组件保留在公共位置,这样我就不必在两个地方进行安装.我创建了组合的通用 package.jsonbower.json 文件并安装了它们。现在我需要更新我各自的 Grunt 文件以使用该公共位置的节点模块。 是否可以从 gruntfile 以外的任何其他位置提供节点模块来运行 grunt 任务。

例如:我希望 client-app-oneclient-app-two 从公共节点模块运行各自的 grunt 任务。

/project-root-dir /project-root-dir/client-app /project-root-dir/client-app-one/Gruntfile.js /project-root-dir/client-app-two/Gruntfile.js /project-root-dir/package.json /project-root-dir/node_modules/ /project-root-dir/bower.json /project-root-dir/bower_componenets/

【问题讨论】:

  • 可能无法回答您的问题,但 IMO 让 2 个独立的应用程序具有相同的依赖项并不是一个好主意。这些文件适合与一个独特的项目相关联,而不是多个。
  • 这个问题已经在here 讨论过......好吧......三年前......
  • @IronGeek 谢谢我检查了讨论并找到了解决方案。

标签: angularjs json node.js gruntjs


【解决方案1】:

here 所述,为我的问题添加解决方案。感谢@IronGeek 在评论中分享链接。 我在 grunt 文件中进行了如下更改以实现上述场景:

Gruntfile.js

var cwd = process.cwd(); process.chdir('../'); require('load-grunt-tasks')(grunt); process.chdir(cwd);

【讨论】:

    猜你喜欢
    • 2020-07-19
    • 2016-08-06
    • 2012-05-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-04-21
    • 2020-09-28
    相关资源
    最近更新 更多