Ember 由于 broccoliBuilderError,构建失败

Ember build failed because of broccoliBuilderError

我在一个 ember 项目中,我正在尝试将 ember 版本从 2.8 升级到 3.5.0。但是由于我更改了版本以及一些依赖项版本,我得到了这个错误:

Error stack

我尝试使用 ember-cli-build 文件修复此问题,但错误仍然存​​在。

const EmberApp = require('ember-cli/lib/broccoli/ember-app');

module.exports = function(defaults) {
    const isPublicEnv = EmberApp.env() === 'public';

    const app = new EmberApp(defaults, {

        'sassOptions': {
            includePaths: [
                'bower_components/materialize/sass',
            ],
        },
        'outputPaths': {
            app: {
                css: {
                    design1: '/assets/design1.css',
                    design2: '/assets/design2.css'
                },
            },
        },
        'ember-cli-babel': {
            includePolyfill: true,
        },
        'minifyJS': {
            enabled: isPublicEnv,
        },
        'minifyCSS': {
            enabled: isPublicEnv,
        },
        'fingerprint': {
            enabled: isPublicEnv,
        },
        'tests': !isPublicEnv,
        'hinting': !isPublicEnv,
        'sourcemaps': {
            enabled: !isPublicEnv,
        },
    });

    app.import('vendor/lib1.js');
    app.import('vendor/lib2.js');

    return app.toTree();
};

有什么解决这个问题的建议吗?

这是来自 ember-cli-htmlbars-inline-precompile 的堆栈跟踪失败的代码:

templateCompilerPath() {
    let config = this.projectConfig();
    let templateCompilerPath = config['ember-cli-htmlbars'] && config['ember-cli-htmlbars'].templateCompilerPath;

    let ember = this.project.findAddonByName('ember-source');
    if (ember) {
      return ember.absolutePaths.templateCompiler;
    }

    return path.resolve(this.project.root, templateCompilerPath);
}

这一行 let ember = this.project.findAddonByName('ember-source'); 一定是罪魁祸首。尽管 Ember 在 2.11 iirc 左右从 bower 切换到 npm,但您获得 Ember > 3.0 的唯一方法是通过 npm,因为最后一个 bower 推送版本是2.x.

我怀疑您使用的是旧版本的 ember-cli,由于未找到 ember,因此也需要进行更新。您使用的 ember-cli 是哪个版本?