0

我正在尝试开始使用 grunt 和 bower 来构建我的项目。所以现在我只想使用 grunt 插件wiredep 将所有已安装的bower 包注入到我的index.html 文件中。

当我尝试运行 grunt 命令时,它总是说:

运行“wiredep:target”(wiredep)任务警告:必须提供模式使用--force 继续。

由于警告而中止。完毕。

我发现其他具有相同错误的主题,但似乎没有一个解决方案对我有用。

这是我的grunfile

module.exports = function (grunt) {

    // Project configuration.
    grunt.initConfig({
        wiredep: {

            target: {
                src: '/public_html/index.html'
            }
        }
    });

    grunt.loadNpmTasks('grunt-wiredep');

};

这是我的bower.json

{
  "name": "GeoSystem",
  "version": "1.0.0",
  "main": "/public_html/js/model.js",
  "ignore": [
    ".jshintrc",
    "**/*.txt"
  ],
  "dependencies": {"jQuery":"3.2.0",
    "arcgis-js-api": "4.3.0",
    "OpenLayers": "4.0.1",
    "bootstrap": "3.3.7"
  },
  "devDependencies": {}
}

这是我的 index.html:

<!DOCTYPE html>
<head>
    <!-- bower:css -->
    <!-- endbower -->
</head>
<body>
    <div class="container">
        <div id="map"></div>
    </div>

    <!-- bower:js -->
    <!-- endbower -->
</body>

有人可以告诉我有什么问题吗?

4

1 回答 1

0

问题在于arcgis-js-api. 它的 bower.json 不提供main导致grunt-wiredep.

https://github.com/taptapship/wiredep

如果要链接它,您需要将它从 grunt-wiredep 目标中排除或覆盖并提供适当的 main。

于 2017-03-21T15:56:17.320 回答