尝试构建ember js项目时出错

时间:2015-03-13 09:37:17

标签: javascript node.js ember.js ember-cli build-error

每当我使用outputPath = dist和environment = production构建我的ember项目时,它构建正常但是当我使用outputPath = dist-something和environment = hosted-something构建时,我得到以下错误:

Build failed.
Invalid mapping: {"generated":{"line":74176,"column":-50},**"source":"bower_components/moment/min/moment.min.js"**,"original
":{"line":1,"column":0},"name":null}
Error: Invalid mapping: {"generated":{"line":74176,"column":-50},"source":"bower_components/moment/min/moment.min.js","o
riginal":{"line":1,"column":0},"name":null}
    at SourceMapGenerator_validateMapping [as _validateMapping] (C:\wamp\www\PublicMD\EmberMD\Ta\trunk\TextAdminLatestEm
ber\node_modules\ember-cli-uglify\node_modules\broccoli-uglify-sourcemap\node_modules\uglify-js\node_modules\source-map\
lib\source-map\source-map-generator.js:272:15)
    at SourceMapGenerator_addMapping [as addMapping] (C:\wamp\www\PublicMD\EmberMD\Ta\trunk\TextAdminLatestEmber\node_mo
dules\ember-cli-uglify\node_modules\broccoli-uglify-sourcemap\node_modules\uglify-js\node_modules\source-map\lib\source-
map\source-map-generator.js:102:12)
    at C:\wamp\www\PublicMD\EmberMD\Ta\trunk\TextAdminLatestEmber\node_modules\ember-cli-uglify\node_modules\broccoli-ug
lify-sourcemap\node_modules\uglify-js\node_modules\source-map\lib\source-map\source-map-generator.js:74:19
    at Array.forEach (native)
    at SourceMapConsumer_eachMapping [as eachMapping] (C:\wamp\www\PublicMD\EmberMD\Ta\trunk\TextAdminLatestEmber\node_m
odules\ember-cli-uglify\node_modules\broccoli-uglify-sourcemap\node_modules\uglify-js\node_modules\source-map\lib\source
-map\source-map-consumer.js:473:10)
    at Function.SourceMapGenerator_fromSourceMap [as fromSourceMap] (C:\wamp\www\PublicMD\EmberMD\Ta\trunk\TextAdminLate
stEmber\node_modules\ember-cli-uglify\node_modules\broccoli-uglify-sourcemap\node_modules\uglify-js\node_modules\source-
map\lib\source-map\source-map-generator.js:50:26)
    at Context.SourceMap (C:\wamp\www\PublicMD\EmberMD\Ta\trunk\TextAdminLatestEmber\node_modules\ember-cli-uglify\node_
modules\broccoli-uglify-sourcemap\node_modules\uglify-js\lib\sourcemap.js:59:52)
    at Object.exports.minify (C:\wamp\www\PublicMD\EmberMD\Ta\trunk\TextAdminLatestEmber\node_modules\ember-cli-uglify\n
ode_modules\broccoli-uglify-sourcemap\node_modules\uglify-js\tools\node.js:112:38)
    at UglifyWriter.processFile (C:\wamp\www\PublicMD\EmberMD\Ta\trunk\TextAdminLatestEmber\node_modules\ember-cli-uglif
y\node_modules\broccoli-uglify-sourcemap\index.js:98:25)
    at C:\wamp\www\PublicMD\EmberMD\Ta\trunk\TextAdminLatestEmber\node_modules\ember-cli-uglify\node_modules\broccoli-ug
lify-sourcemap\index.js:46:14
如果有人能让我知道原因是什么以及解决方案,那将会很棒

当uglifyJs解析brocfile.js时似乎是一个错误。由于目前在brcofile.js中我使用以下行

app.import('bower_components/moment/min/moment.min.js');
app.import('bower_components/jquery-file-upload/js/vendor/jquery.ui.widget.js');
app.import('bower_components/jquery-file-upload/js/jquery.iframe-transport.js');
app.import('bower_components/jquery-file-upload/js/jquery.fileupload.js');

但是,当我使用以下订单时,

app.import('bower_components/jquery-file-upload/js/vendor/jquery.ui.widget.js');
app.import('bower_components/jquery-file-upload/js/jquery.iframe-transport.js');
app.import('bower_components/jquery-file-upload/js/jquery.fileupload.js');
app.import('bower_components/moment/min/moment.min.js');

错误变为

  

构建失败。无效的映射:   { “生成”:{ “行”:74174, “塔”: - 50}, “源”:“bower_components / jQuery的文件上传/ JS /供应商/ jquery的   .ui.widget.js“,”original“:{”line“:1,”column“:0},”name“:null}错误:   无效的映射:   { “生成”:{ “行”:74174, “塔”: - 50}, “源”:“bower_components / jQuery的文件上传/ JS /供应商   /jquery.ui.widget.js","original":{"line":1,"column":0},"name":null}       在SourceMapGenerator_validateMapping [as _validateMapping](C:\ wamp \ www \ PublicMD \ EmberMD \ Ta \ trunk \ TextAdminLatestEm   BER \ node_modules \烬-CLI-丑化\ node_modules \西兰花,丑化,sourcemap \ node_modules \丑化-JS \ node_modules \ sourcemap \   LIB \源地图\源-MAP-generator.js:272:15)

*********根据评论建议******更新整个borcfile

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


var isProduction = ['production', 'hosted-something'].indexOf(process.env.EMBER_ENV) > -1;

var app = new EmberApp({

    fingerprint: {
        enabled: false
    },

    hinting: !isProduction,

    minifyCSS: {
        enabled: isProduction
    },

    minifyJS: {
        enabled: isProduction
    },

    storeConfigInMeta: false,

    tests: !isProduction,

    vendorFiles: {        
        'jquery.js': 'bower_components/jquery/dist/jquery.js',

        'handlebars.js': null,

        'ember.js': {
            'hosted-something':  'bower_components/ember/ember.prod.js'
        },

    },

    wrapInEval: !isProduction
});

if (app.env !== 'hosted-something') {
    app.import('bower_components/bootstrap-go/index.css');
    app.import('bower_components/bootstrap-go-responsive/index.css');
}

app.import('bower_components/moment/min/moment.min.js');
app.import('bower_components/jquery-file-upload/js/vendor/jquery.ui.widget.js');
app.import('bower_components/jquery-file-upload/js/jquery.iframe-transport.js');
app.import('bower_components/jquery-file-upload/js/jquery.fileupload.js');

module.exports = app.toTree();

1 个答案:

答案 0 :(得分:1)

将以下内容添加到您的brocfile:

sourcemaps: {
  enabled: !isProduction
}

您获得的错误是由于构建尝试在运行“生产”构建时生成源映射。