Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/webpack/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用动态导入的typescript中出现错误_Typescript_Webpack_Vue.js - Fatal编程技术网

使用动态导入的typescript中出现错误

使用动态导入的typescript中出现错误,typescript,webpack,vue.js,Typescript,Webpack,Vue.js,我得到以下错误 ERROR in [at-loader] ./ClientApp/boot.ts:7:23 TS1109: Expression expected. ERROR in [at-loader] ./ClientApp/boot.ts:7:29 TS1134: Variable declaration expected. ERROR in [at-loader] ./ClientApp/boot.ts:8:25 TS1109: Expression ex

我得到以下错误

ERROR in [at-loader] ./ClientApp/boot.ts:7:23 
    TS1109: Expression expected.
ERROR in [at-loader] ./ClientApp/boot.ts:7:29 
    TS1134: Variable declaration expected.
ERROR in [at-loader] ./ClientApp/boot.ts:8:25 
    TS1109: Expression expected.
ERROR in [at-loader] ./ClientApp/boot.ts:8:31 
    TS1134: Variable declaration expected.
我有以下boot.ts文件

import './css/site.css';
import 'bootstrap';
import Vue from 'vue';
import VueRouter from 'vue-router';
Vue.use(VueRouter);

const Counter = () => import('./components/counter/counter');
const FetchData = () => import('./components/fetchdata/fetchdata');

const routes = [
    { path: '/', component: require('./components/home/home.vue.html') },
    { path: '/counter', component: Counter },
    { path: '/fetchdata', component: FetchData }
];

new Vue({
    el: '#app-root',
    router: new VueRouter({ mode: 'history', routes: routes }),
    render: h => h(require('./components/app/app.vue.html'))
});
我的tsconfig.json文件如下所示

{
  "compilerOptions": {
    "allowSyntheticDefaultImports": true,
    "experimentalDecorators": true,
    "module": "esnext",
    "moduleResolution": "node",
    "target": "es5",
    "sourceMap": true,
    "skipDefaultLibCheck": true,
    "strict": true,
    "importHelpers": true,
    "lib": [
      "es5",
      "es2015.promise"
  ],
    "types": ["webpack-env"]
  },
  "exclude": [
      "bin",
      "node_modules"
  ]
}
我想实现以下目标。我正在使用网页包。因此,如果需要,我可以在这里发布


动态导入语法仅在2.4+版本的Typescript中受支持。最可能的修复方法是您需要升级您的Typescript版本

使用以下命令更新Typescript的版本:

npm update --save-dev typescript
或者,如果您使用的是全局安装的版本:

npm update -g typescript

您可以在之后运行
npm list typescript
(或
npm list-g typescript
),以确保它成功运行。

您使用的是什么版本的typescript?2.4.1版本之前不支持动态导入语法。我对这个很陌生。但是我的package.json看起来像这样。“typescript”:“^2.2.1”,如果运行
npm list typescript
,输出是什么?嘿,伙计。我尝试了npm更新--保存。现在是新的错误。TS2304:找不到名称“Node”。您的命令显示:`--typescript@2.7.2