1

I've been working on my angular 2 app yesterday and everything ran fine. Today I was trying to npm start my app and I get this compile error:

typings/browser/ambient/moment/index.d.ts(9,21): error TS2503: Cannot find namespace 'moment'.

Although I didn't mention anything releaeted to moment in my app!

What can cause this error if I'm not using anything releated to moment?

I tried:

  1. The solutions here
  2. npm remove moment

Any ideas?

Community
  • 1
  • 1
TheUnreal
  • 23,434
  • 46
  • 157
  • 277

1 Answers1

8

I had the same problem. Just fixed it.

When you run:

typings install moment --ambient --save

You'll likely see an info message like this:

typings INFO reference Stripped reference "https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/56295f5058cac7ae458540423c50ac2dcf9fc711/moment/moment-node.d.ts" during installation from "moment"

This was my clue that I also needed to install the typings for moment-node and then everything worked.

typings install moment-node --ambient --save

Good luck!

lostdorje
  • 6,150
  • 9
  • 44
  • 86
  • 4
    @Eusthace, the `--ambient` flag was replaced by `--global`, and you now have to specify the source (definitely typed = `dt~`). The following worked for me: `typings install dt~moment-node --global --save`. – Courtney Christensen Jul 01 '16 at 20:04