lang.js:21 Uncaught SyntaxError:意外的令牌导出

时间:2016-09-22 08:31:02

标签: javascript angular facade lang

enter image description here 我的package.json

<code class="language-liquid" data-lang="liquid">  
  <span class="p">{{</span>
  <span class="w"> </span>
  <span class="nv">Your code here</span>
  <span class="w"> </span>
  <span class="p">}}</span>
</code>

解决方案

您可以在webpack.config.js

中使用babel-loader来解决此问题
"ng2-file-upload": "1.0.3",
"ng2-translate": "2.5.0",
"angular2-cookie": "1.2.3",
"angular2-google-maps": "0.15.0",
"key-codes": "0.0.1",
"rxjs": "5.0.0-beta.12"
"@angular/common":  "2.0.0",
"@angular/compiler":  "2.0.0",
"@angular/core":  "2.0.0",
"@angular/forms": "2.0.0",
"@angular/http":  "2.0.0",
"@angular/platform-browser":  "2.0.0",
"@angular/platform-browser-dynamic":  "2.0.0",
"@angular/router":  "3.0.0",
"@angular/upgrade":  "2.0.0",
"systemjs": "0.19.27",
"core-js": "^2.4.1",
"reflect-metadata": "^0.1.3",
"rxjs": "5.0.0-beta.12",
"zone.js": "^0.6.23",
"angular2-in-memory-web-api": "0.0.20",
"bootstrap": "3.3.6",
"es6-promise": "3.2.1",
"es6-shim": "0.35.1",
"ie-shim": "0.1.0",
"jquery": "2.2.4",
"moment": "^2.14.1",
"theuy-bootstrap-datetimepicker": "^1.0.0"

之后你可以添加

npm install --save-dev babel-loader babel-preset-es2015

问题是角度团队没有将外观导出为es5代码,而是es6。

1 个答案:

答案 0 :(得分:0)

您可以在webpack.config.js

中使用babel-loader来解决此问题
npm install --save-dev babel-loader babel-preset-es2015

之后你可以添加

//webpack.config.js
module.exports = {
    // configuration
loaders: [
        {
            test: /\.js$/,
            exclude: /node_modules\/(?!(@angular\/common\/src\/facade\/.+))/,
            loader: 'babel?presets[]=es2015'
        }
    ]
};

问题是角度团队没有将外观导出为es5代码,而是es6。