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 节点_模块/@类型中的网页包ts加载程序错误_Typescript_Webpack_Ts Loader - Fatal编程技术网

Typescript 节点_模块/@类型中的网页包ts加载程序错误

Typescript 节点_模块/@类型中的网页包ts加载程序错误,typescript,webpack,ts-loader,Typescript,Webpack,Ts Loader,我的项目编译得很好,但是如果我在新目录中签出并尝试npm安装然后是webpack,我会出现以下错误: ERROR in /home/nobody/myproject/server/node_modules/@types/mongodb/index.d.ts (500,12): error TS1005: ',' expected. ERROR in /home/nobody/myproject/server/node_modules/@types/mongodb/index.d.ts (502

我的项目编译得很好,但是如果我在新目录中签出并尝试npm安装然后是webpack,我会出现以下错误:

ERROR in /home/nobody/myproject/server/node_modules/@types/mongodb/index.d.ts
(500,12): error TS1005: ',' expected.

ERROR in /home/nobody/myproject/server/node_modules/@types/mongodb/index.d.ts
(502,12): error TS1005: ',' expected.

ERROR in /home/nobody/myproject/server/node_modules/@types/mongodb/index.d.ts
(504,15): error TS1005: ',' expected.

ERROR in /home/nobody/myproject/server/node_modules/@types/mongodb/index.d.ts
(505,15): error TS1005: ',' expected.

ERROR in /home/nobody/myproject/server/node_modules/@types/mongodb/index.d.ts
(506,15): error TS1005: ',' expected.

ERROR in /home/nobody/myproject/server/node_modules/@types/mongodb/index.d.ts
(1002,23): error TS1005: ',' expected.
同一文件中还有大约25个其他错误,以及我的一些源文件中的其他错误

在我的tsconfig.json中,我排除了node_模块,并且我还设置了用于使用node express后端打包node_模块的webpack externals:

var nodeModules = {};
fs.readdirSync('node_modules')
    .filter(function (x) {
        return ['.bin'].indexOf(x) === -1;
    })
    .forEach(function (mod) {
        nodeModules[mod] = 'commonjs ' + mod;
    });

我真正不明白的是,为什么在我的开发目录中一切都很好,但如果我把它放在另一个目录中,它就会崩溃。

您使用的是什么版本的TypeScript?文件开始使用默认类型参数,这些参数在TypeScript 2.3中发布。文件中还有20多个默认类型参数,这听起来像是您看到的解析错误的数量


简而言之,您可能需要升级到TypeScript 2.3。

我想给您大约100万分,但请不要让我单击多次。。。