使用sails时,我是否需要在package.json中显式grunt

时间:2015-10-24 10:17:09

标签: node.js gruntjs npm sails.js

我有sails lift app和main package.json,如下所示。 如果帆也有它们,我真的需要所有那些咕噜声。特别是如果帆在版本0.4.5中咕噜咕噜,这里我有0.4.2 无论如何在主应用程序包package.json中没有grunt条目。 { ... "dependencies": { "ejs": "~0.8.4", "grunt": "0.4.2", "grunt-contrib-clean": "~0.5.0", "grunt-contrib-coffee": "~0.10.1", "grunt-contrib-concat": "~0.3.0", "grunt-contrib-copy": "~0.5.0", "grunt-contrib-cssmin": "~0.9.0", "grunt-contrib-jst": "~0.6.0", "grunt-contrib-less": "0.11.1", "grunt-contrib-sass": "^0.9.2", "grunt-contrib-uglify": "~0.4.0", "grunt-contrib-watch": "~0.5.3", "grunt-sails-linker": "~0.9.5", "grunt-sync": "~0.0.4", "include-all": "~0.1.3", "mongodb": "^2.0.41", "rc": "~0.5.0", "sails": "git://github.com/balderdashy/sails.git", "sails-disk": "~0.10.0", "sails-mongo": "^0.11.2" } ... } 后出现错误。这看起来有些不一致。

<div class="sidebar-nav">
    <ul>
        <li><a href="#" data-target=".master-menu" class="nav-header" data-toggle="collapse"><i class="fa fa-fw fa-dashboard"></i>Master <i class="fa fa-collapse"></i></a></li>
        <li>
            <ul class="master-menu nav nav-list collapse in">
                <li><a href="~/InventoryModule/MasterPages/Metals/MetalDetails.aspx" runat="server"><span class="fa fa-caret-right"></span>Metal</a></li>
                <li><a href="~/InventoryModule/MasterPages/Party/add_party_details.aspx" runat="server"><span class="fa fa-caret-right"></span>Party </a></li>
                <li><a href="~/InventoryModule/MasterPages/Production/Production_Details.aspx" runat="server"><span class="fa fa-caret-right"></span>Production</a></li>
            </ul>
        </li>

        <li><a href="#" data-target=".transaction-menu" class="nav-header collapsed" data-toggle="collapse"><i class="fa fa-fw fa-dashboard"></i>Transaction <i class="fa fa-collapse"></i></a></li>
        <li>
            <ul class="transaction-menu nav nav-list collapse">
                <li><a href="~/InventoryModule/MasterPages/CustomerTransaction/Customer_Transaction.aspx" runat="server"><span class="fa fa-caret-right"></span>Customer Transaction</a></li>
                <li><a href="~/InventoryModule/CustomerTransactionDetails.aspx" runat="server"><span class="fa fa-caret-right"></span>Customer Transaction Details </a></li>
                <li><a href="~/InventoryModule/MasterPages/return_goods.aspx" runat="server"><span class="fa fa-caret-right"></span>Return Goods</a></li>
                <li><a href="~/InventoryModule/MasterPages/Loss.aspx" runat="server"><span class="fa fa-caret-right"></span>Loss</a></li>
                <li><a href="~/InventoryModule/Debit.aspx" runat="server"><span class="fa fa-caret-right"></span>Debit</a></li>
                <li><a href="~/InventoryModule/Labour_Charges.aspx" runat="server"><span class="fa fa-caret-right"></span>Return Direct Goods</a></li>
                <li><a href="~/InventoryModule/finished_goods_Details.aspx" runat="server"><span class="fa fa-caret-right"></span>Finished Goods</a></li>
                <li><a href="~/InventoryModule/MasterPages/Loss_f_goods.aspx" runat="server"><span class="fa fa-caret-right"></span>Finished Goods Loss</a></li>
                <li><a href="~/InventoryModule/DirectStock.aspx" runat="server"><span class="fa fa-caret-right"></span>Direct Stock Entry</a></li>
                <li><a href="~/InventoryModule/MasterPages/Stock Transfer/Stock_Transfer.aspx" runat="server"><span class="fa fa-caret-right"></span>Stock Transfer</a></li>
                <li><a href="~/InventoryModule/Metal_Labelling.aspx" runat="server"><span class="fa fa-caret-right"></span>Metal Labelling</a></li>

            </ul>
        </li>

        <li><a href="#" data-target=".accounting-menu" class="nav-header collapsed" data-toggle="collapse"><i class="fa fa-fw fa-dashboard"></i>Accounting <i class="fa fa-collapse"></i></a></li>
        <li>
            <ul class="accounting-menu nav nav-list collapse">
                <li><a href="~/InventoryModule/LedgerMaster.aspx" runat="server"><span class="fa fa-caret-right"></span>Ledger Master</a></li>
                <li><a href="~/InventoryModule/MasterPages/Daily Expenditure/daily_expenditure.aspx" runat="server"><span class="fa fa-caret-right"></span>Daily Expenditure </a></li>
                <li><a href="~/InventoryModule/DailyReport.aspx" runat="server"><span class="fa fa-caret-right"></span>Daily Report</a></li>
                <li><a href="~/InventoryModule/CashReport1.aspx" runat="server"><span class="fa fa-caret-right"></span>Cash Report</a></li>
                <li><a href="~/InventoryModule/SaleCustomerReport.aspx" runat="server"><span class="fa fa-caret-right"></span>Sale Report</a></li>
                <li><a href="~/InventoryModule/VendorSaleReport.aspx" runat="server"><span class="fa fa-caret-right"></span>Vender Transaction Report</a></li>
                <li><a href="~/InventoryModule/Transactions.aspx" runat="server"><span class="fa fa-caret-right"></span>Transaction Report</a></li>
            </ul>
        </li>
</div>

1 个答案:

答案 0 :(得分:2)

是的,你必须保留它们。如果您想要进行整合,那么错误是什么?尝试删除它们并删除项目的node_modules文件夹并运行npm install,您将看到您将无法运行像default这样的grunt任务,因为所需的所有插件都不是在package.json注册。您是项目的创建者,因此当您使用sails new app创建应用程序时,项目的所有npm依赖项都是别名,并指向全局安装的sails节点模块的node_modules文件夹。

我举一个例子来说明问题: 所有依赖项都没有集成到版本控制系统(最佳实践),然后node_modules文件夹将被忽略。如果协作者拉动项目,他必须运行npm install来安装所有项目依赖项,如果你从package.json删除了所有grunt插件,他将无法运行grunt任务,因为所有所需的插件未在package.json注册。

如果您要停用grunt集成,请将其添加到.sailsrc文件中:

"hooks": {
    "grunt": false
}

要了解如何将grunt集成到风帆,我建议您阅读文档,尤其是以下部分:
- disabling-grunt
- task-automation
- default-tasks