Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/32.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
Angular TypeScript找不到名称Weakmap、Map等_Angular_Typescript_Webpack - Fatal编程技术网

Angular TypeScript找不到名称Weakmap、Map等

Angular TypeScript找不到名称Weakmap、Map等,angular,typescript,webpack,Angular,Typescript,Webpack,我准备了一个教程,并配置了这个ts和web包 这是Tconfig { "compilerOptions": { "target": "es5", "module": "es2015", "moduleResolution": "node", "sourceMap": true, "emitDecoratorMetadata": true, "experimentalDecorators": true, "lib": ["es6", "dom"], "noImpli

我准备了一个教程,并配置了这个ts和web包

这是Tconfig

{
"compilerOptions": {
  "target": "es5",
  "module": "es2015",
  "moduleResolution": "node",
  "sourceMap": true,
  "emitDecoratorMetadata": true,
  "experimentalDecorators": true,
  "lib": ["es6", "dom"],
  "noImplicitAny": true,
  "suppressImplicitAnyIndexErrors": true,
  "typeRoots": [
    "node_modules/@types/"
  ]
},
"exclude": [
    "node_modules"
]
}

这里是webpack.config.js

    var path = require('path');
var webpack = require('webpack');
var UglifyJSPlugin = require('uglifyjs-webpack-plugin'); 
module.exports = {
    entry: {
        'polyfills': './src/polyfills.ts',
        'app': './src/main.ts'
      },
   output:{
       path: path.resolve(__dirname, './public'),    
       publicPath: '/public/',
       filename: "[name].js"      
   },
   resolve: {
    extensions: ['.ts', '.js']
  },
   module:{
       rules:[   
           {
               test: /\.ts$/, 
               use: [
                {
                    loader: 'awesome-typescript-loader',
                    options: { configFileName: path.resolve(__dirname, 'tsconfig.json') }
                  } ,
                   'angular2-template-loader'
               ]
            }
       ]
   },
   plugins: [
    new webpack.ContextReplacementPlugin(
        /angular(\\|\/)core/,
        path.resolve(__dirname, 'src'), 
      {} 
    ),
    new UglifyJSPlugin()
  ]
}
这是我的项目根

但是当我运行这个项目时,我得到了这些错误

[at loader]。/node_modules/@types/node/index.d.ts:6208:55中出错 TS2304:找不到名称“Map”

[at loader]。/node_modules/@types/node/index.d.ts:6215:55中出错 TS2304:找不到名称“Set”

[at loader]。/node_modules/@types/node/index.d.ts:6225:59中出现错误 TS2304:找不到名称“WeakMap”

[at loader]./node_modules/@types/node/index.d.ts:6226:59中出错 TS2304:找不到名称“WeakSet”

这是终端的完整日志


如何修复此问题?

安装corejs类型

npm安装-保存dev@types/core js

同时将其添加到tsConfig

{
"compilerOptions": {
  "target": "es5",
  "module": "es2015",
  "moduleResolution": "node",
  "sourceMap": true,
  "emitDecoratorMetadata": true,
  "experimentalDecorators": true,
  "lib": ["es6", "dom"],
  "noImplicitAny": true,
  "suppressImplicitAnyIndexErrors": true,
  "typeRoots": [
    "node_modules/@types/"
  ],
  "types": [
     "core-js"
   ]
},

仍然有这个问题,检查一下我在帖子里做的,但它仍然不起作用。可能问题出在网页配置和路径中?问题出在哪里?不,我只是删除了项目并重新创建了它