Parsing error: Unexpected token错误怎么办
mport鍔ㄦ佸鍏ワ紝灏唈s鏂囦欢鍗曠嫭鎵撳寘鏃讹紝webpack鎵撳寘閿欒
import('./test')
.then((res) => {
// 鏂囦欢鍔犺浇鎴愬姛
console.log(res.mul(2, 5));
})
.catch(() => {
console.log('鏂囦欢鍔犺浇澶辫触');
});
鏋勫缓鍑洪敊锛
ERROR in ./src/js/index.js
Module Error (from ../../node_modules/_eslint-loader@4.0.2@eslint-loader/dist/cjs.js):
D:\project\gitOwn\webpack\23-code split\demo3\src\js\index.js
19:7 error Parsing error: Unexpected token (
鉁 1 problem (1 error, 0 warnings)
鍒嗘瀽锛
绂佺敤eslint锛寃ebpack鎵撳寘姝e父锛孭arsing error 鏄痚slint瑙f瀽閿欒銆
瑙e喅鍔炴硶锛
1.涓嬭浇 babel-eslint 鎻掍欢锛圢pm涓嬭浇浼氬嚭閿欙級
cnpm install babel-eslint --save
2.鍦╬ackage.json涓厤缃 eslintConfig 灞炴
"eslintConfig": {
"extends": "airbnb-base",
"parser": "babel-eslint"
}
import('./test')
.then((res) => {
// 鏂囦欢鍔犺浇鎴愬姛
console.log(res.mul(2, 5));
})
.catch(() => {
console.log('鏂囦欢鍔犺浇澶辫触');
});
鏋勫缓鍑洪敊锛
ERROR in ./src/js/index.js
Module Error (from ../../node_modules/_eslint-loader@4.0.2@eslint-loader/dist/cjs.js):
D:\project\gitOwn\webpack\23-code split\demo3\src\js\index.js
19:7 error Parsing error: Unexpected token (
鉁 1 problem (1 error, 0 warnings)
鍒嗘瀽锛
绂佺敤eslint锛寃ebpack鎵撳寘姝e父锛孭arsing error 鏄痚slint瑙f瀽閿欒銆
瑙e喅鍔炴硶锛
1.涓嬭浇 babel-eslint 鎻掍欢锛圢pm涓嬭浇浼氬嚭閿欙級
cnpm install babel-eslint --save
2.鍦╬ackage.json涓厤缃 eslintConfig 灞炴
"eslintConfig": {
"extends": "airbnb-base",
"parser": "babel-eslint"
}