Skip to content
This repository was archived by the owner on Apr 23, 2023. It is now read-only.
This repository was archived by the owner on Apr 23, 2023. It is now read-only.

TSC Cannot find name 'module'. #1

@ackzell

Description

@ackzell

Hello,

I was following the tutorial and got the following error on my terminal after attempting $ npm run hmr:

Module build failed: Error: <MY_APP_PATH>/src/main.ts (19,7): Cannot find name 'module'.)

As a side note, my editor (VSCode) would complain that it didn't find the module name either.

solution
After some research, I figured I would probably need @types/webpack-env and so I added it to my CLI () generated project. This actually fixed it. I can now use HMR in a very simple app!

The tsconfig.json file also needed to know that it should look for those definitions (I think), so the "types" key now looks like:

"types": [
     .
     .
     .,
      "webpack-env"
    ]

Just wanted to share it in case someone else would bump into the same thing.

And to give a little more context this is my CLI environment right now:

angular-cli: 1.0.0-beta.24
node: 6.9.1
os: darwin x64
@angular/common: 2.4.0
@angular/compiler: 2.4.0
@angular/core: 2.4.0
@angular/forms: 2.4.0
@angular/http: 2.4.0
@angular/material: 2.0.0-alpha.11-3
@angular/platform-browser: 2.4.0
@angular/platform-browser-dynamic: 2.4.0
@angular/router: 3.4.0
@angular/compiler-cli: 2.4.0```

I'd be glad to know if there is another / better solution to this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions