1

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 Answer 1

-1

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"
   ]
},
Sign up to request clarification or add additional context in comments.

5 Comments

Still have this problem
I make all like in post, but it still not works. Maybe problem is in webpack config and in path?
what was the prblem
dunno, I just delete project and recreate it

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.