1
votes

I going thought angular tutorial and have this ts and web pack configs

Here is 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/"
  ]
},
"exclude": [
    "node_modules"
]

}

And here is 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()
  ]
}

Here are my project roots

Screen

But when I run the project, I get those errors.

ERROR in [at-loader] ./node_modules/@types/node/index.d.ts:6208:55 TS2304: Cannot find name 'Map'.

ERROR in [at-loader] ./node_modules/@types/node/index.d.ts:6215:55 TS2304: Cannot find name 'Set'.

ERROR in [at-loader] ./node_modules/@types/node/index.d.ts:6225:59 TS2304: Cannot find name 'WeakMap'.

ERROR in [at-loader] ./node_modules/@types/node/index.d.ts:6226:59 TS2304: Cannot find name 'WeakSet'.

Here is a full log from terminal

https://pastebin.com/jyRLSn42

How I can fix this?

1

1 Answers

-1
votes

Install the types corejs

npm install --save-dev @types/core-js

Also add it to the 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"
   ]
},