0

As the title suggests I have an internal module in which I require an external module (in this case momentjs) If I just have the module definition and reference this in my other files it compiles fine but of course at runtime I get a 'moment is not defined' error. If I then add:

import moment = require('moment');

then the module gets wrapped in the appropriate require([.....]) code but now my other files won't compile due to the module reference not being found.

What is the best way to fix this?

1 Answer 1

1

To fix this issue, make sure you have the moment TypeScript definition file included in your project and referenced.

TypeScript definitions

You can include moment as follows:

var moment: moment.MomentStatic = require('moment');
Sign up to request clarification or add additional context in comments.

1 Comment

I see I was using the require syntax incorrectly for my needs. Works perfectly - Thanks!

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.