更新项目依赖项后,我开始看到此错误,object-assign
Babel 5插件似乎存在版本控制问题。
更新后我使用Babel 6,我能找到的最接近的插件是es6-object-assign
,但使用它会导致错误(如下所示)。
在我的应用中使用browserify
+ babelify
+ object-assign
:
var babelify = require('babelify');
var browserify = require('browserify-middleware');
var keystone = require('keystone');
var importRoutes = keystone.importer(__dirname);
// Setup Route Bindings
exports = module.exports = function(app) {
app.use('/js', browserify('./client/scripts', {
transform: [babelify.configure({
plugins: ['object-assign']
})]
}));
// Views
app.use(function(req, res) {
res.render('index');
});
};
服务器日志:
GET / 304 260.457 ms
Error thrown for request: /js/Application.js
Error: The (object-assign) Babel 5 plugin is being run with Babel 6. while parsing file: /home/user/project/client/scripts/Application.js
at new Plugin (/home/user/project/node_modules/babel-core/lib/api/node.js:96:9)
at exports.default (/home/user/project/node_modules/babel-plugin-object-assign/lib/index.js:11:10)
at Function.memoisePluginContainer (/home/user/project/node_modules/babel-core/lib/transformation/file/options/option-manager.js:109:13)
at Function.normalisePlugin (/home/user/project/node_modules/babel-core/lib/transformation/file/options/option-manager.js:142:32)
at /home/user/project/node_modules/babel-core/lib/transformation/file/options/option-manager.js:180:30
at Array.map (native)
at Function.normalisePlugins (/home/user/project/node_modules/babel-core/lib/transformation/file/options/option-manager.js:154:20)
at OptionManager.mergeOptions (/home/user/project/node_modules/babel-core/lib/transformation/file/options/option-manager.js:229:36)
at OptionManager.init (/home/user/project/node_modules/babel-core/lib/transformation/file/options/option-manager.js:374:12)
at File.initOptions (/home/user/project/node_modules/babel-core/lib/transformation/file/index.js:216:65)
at new File (/home/user/project/node_modules/babel-core/lib/transformation/file/index.js:139:24)
at Pipeline.transform (/home/user/project/node_modules/babel-core/lib/transformation/pipeline.js:46:16)
at Babelify._flush (/home/user/project/node_modules/babelify/index.js:27:24)
at Babelify.<anonymous> (_stream_transform.js:118:12)
at Babelify.g (events.js:291:16)
at emitNone (events.js:86:13)
更改为plugins: ['es6-object-assign']
时出错,可能是因为babelify需要object-assign
node_modules/babelify/index.js
行var assign = require("object-assign");
上的原始GET / 304 280.365 ms
Error thrown for request: /js/Application.js
Error: Plugin 0 specified in "base" provided an invalid property of "assign" while parsing file: /home/user/project/client/scripts/Application.js
at Plugin.init (/home/user/project/node_modules/babel-core/lib/transformation/plugin.js:131:13)
at Function.normalisePlugin (/home/user/project/node_modules/babel-core/lib/transformation/file/options/option-manager.js:148:12)
at /home/user/project/node_modules/babel-core/lib/transformation/file/options/option-manager.js:180:30
at Array.map (native)
at Function.normalisePlugins (/home/user/project/node_modules/babel-core/lib/transformation/file/options/option-manager.js:154:20)
at OptionManager.mergeOptions (/home/user/project/node_modules/babel-core/lib/transformation/file/options/option-manager.js:229:36)
at OptionManager.init (/home/user/project/node_modules/babel-core/lib/transformation/file/options/option-manager.js:374:12)
at File.initOptions (/home/user/project/node_modules/babel-core/lib/transformation/file/index.js:216:65)
at new File (/home/user/project/node_modules/babel-core/lib/transformation/file/index.js:139:24)
at Pipeline.transform (/home/user/project/node_modules/babel-core/lib/transformation/pipeline.js:46:16)
at Babelify._flush (/home/user/project/node_modules/babelify/index.js:27:24)
at Babelify.<anonymous> (_stream_transform.js:118:12)
at Babelify.g (events.js:291:16)
at emitNone (events.js:86:13)
at Babelify.emit (events.js:185:7)
at prefinish (_stream_writable.js:478:12)
包:
#divname {
position:absolute;
top:50%;
left:50%;
transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
-webkit-transform: translate(-50%, -50%);
}