繁体   English   中英

Ember-CLI:找不到模块'broccoli-static-compiler'错误:无法找到模块'broccoli-static-compiler'

[英]Ember-CLI: Cannot find module 'broccoli-static-compiler'Error: Cannot find module 'broccoli-static-compiler'

谁知道这个错误意味着什么? 最重要的是:如何解决?

Cannot find module 'broccoli-static-compiler'Error: Cannot find module 'broccoli-static-compiler'

这是在安装ember-cli新项目并尝试运行ember server

这意味着ember serve找不到Node.js包broccoli-static-compiler Broccoli为Ember CLI项目提供构建管道,broccoli broccoli-static-compiler是一个Broccoli插件,可以按原样将文件复制到构建输出。

我不能用Ember CLI 0.0.280.0.29重现这个,这个包应该YOURPROJECT/node_modules/ember-cli/node_modules/ 您安装了哪个版本的Ember CLI? ember --version

你可以尝试安装broccoli-static-compiler通过运行在本地自己为新项目npm install --save-dev broccoli-static-compiler从项目目录。

西兰花静态编译器

(1)安装所需的西兰花扩展:

npm install --save-dev broccoli-static-compiler
npm install --save-dev broccoli-merge-trees

(2)编辑Brocfile.js

删除或评论此行:

module.exports = app.toTree();

添加(并修改以适应):

// require the static compiler
var pickFiles = require('broccoli-static-compiler');
// choose the static files - path usually: 'vendor/module/dist'
var iCanHasFiles = pickFiles('path/to/files', {
    srcDir: '/',
    // 'files' is optional for choosing some of the srcDir's content.
    // NB: Do not include directories here!
    files: ['file.js', 'file.css', 'file.woff'],
    destDir: '/assets/icanhasfiles'
});

// Merge the iCanHasFiles with the ember app tree
var mergeTrees = require('broccoli-merge-trees');
module.exports = mergeTrees([app.toTree(), iCanHasFiles]);

(3)其他JavaScript文件也可以通过这个文件添加。 它们必须插入到Brocfile.js中的module.exports调用之上

// after "bower install --save bower-module-name" (bower.io/search for name).
app.import('vendor/module/file.js');

Ember-cli和Bootstrap

(A)使用Bootstrap包含创建新项目应用项目的说明:

ember new app-project
cd app-project
bower install --save bootstrap-sass-official
npm install --save-dev broccoli-sass
mv app/styles/app.css app/styles/app.scss

(B)打开app / styles / app.scss ,并更改导入路径:

@import 'vendor/bootstrap-sass-official/vendor/assets/stylesheets/bootstrap';

(C)要包含Glyphicons字体,请打开Brocfile.js

// import the necessary modules:
var pickFiles = require('broccoli-static-compiler');
var mergeTrees = require('broccoli-merge-trees');

// at the bottom of the file, replace the "module.exports" line with:
// module.exports = app.toTree();

// Put the bootstrap fonts in the place that the bootstrap css expects to find them.
var bootstrapFonts = pickFiles('vendor/bootstrap-sass-official/vendor/assets/fonts/bootstrap', {
    srcDir: '/',
    destDir: '/assets/bootstrap'
});

// Merge the bootstrapFonts with the ember app tree
var mergeTrees = require('broccoli-merge-trees');
module.exports = mergeTrees([
    app.toTree(),
    bootstrapFonts
]);

(D)或者,对于经典的glyphicons(bootstrap 2.3等):

// if using glyphicons instead (bootstrap 2.3 etc):
var glyphicons = pickFiles('vendor/bootstrap-sass-official/vendor/assets/fonts/bootstrap', {
    srcDir: '/',
    files: [
        'glyphicons-halflings-regular.*',
    ],
    destDir: '/assets/bootstrap'
});

// Merge the glyphicons with the ember app tree
module.exports = mergeTrees([
    app.toTree(),
    glyphicons
]);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM