我最近使用Yeoman通过silverstripe-module生成器搭建了一个新的Silverstripe项目。我有npm 2.15.0,节点是4.4.2,并且在运行生成器之前还更新了lodash。
现在,在我的开发环境中(Aptana工作室3),我克隆了一个git repo(这是一个空的私人仓库),然后运行生成器以在其中搭建一个新项目。
一切正常。只是有关更新graceful-fs的警告。
但是,在Javascript和node_modules> babel-core文件夹中弹出了一些JS错误。它们都是“语法错误:意外的令牌”错误。
例如。在javascript文件夹中,有两个文件,即使是简单的关键字(例如“ import”和“ class”)也都显示为意外标记。
import is the unexpected token in Main.js:
/**
* This is the entry point to your front-end application.
* Browserify will create a dependency graph starting from this file,
* the result will be bundled, and written to javascript/dist/bundle.js which
* you can include using Requirements::javascript in your controller.
*/
import ExampleComponent from './example-component';
$('.example-component-wrapper').entwine({
onadd: function () {
var component = new ExampleComponent();
component.doStuff();
}
});
class和export是example-component.js中意外的标记:
/**
* A component that can do stuff.
*/
class ExampleComponent {
constructor() {
}
doStuff() {
return true;
}
}
export default ExampleComponent;
在node_modules文件夹中有很多这样的错误。有任何想法吗?
最佳答案
正如上面@FinBoWa所评论的那样,开发环境是问题所在。它不支持ES6。
stackoverflow.com/questions/30901152/does-aptana-support-es6
关于javascript - silverstripe-模块yeoman生成器中的JS意外 token 错误,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/36475624/