0

I created a TypeScript's class and published it on npm
https://www.npmjs.com/package/mds.persian.calendar

I installed it in a Angular project as the following command:
npm install mds.persian.calendar --save

It installed successfully, and I can see the mds.persian.calendar folder in node_modules folder but when I want to use it in my TypeScript file as the following code, it alert can not find module
import { MdsPersianCalendar } from 'MdsPersianCalendar';

How should I use it?

1
  • You have to use the correct package name. It is register as mds.persian.calendar in npm. Commented Apr 28, 2017 at 6:29

1 Answer 1

2

In mds.persian.calendar/package.json this config is missing:

{
    ...
    "main": "./mds.persian.calendar.js",
    "types": "./mds.persian.calendar.d.ts"
}

That's why you need to reference this module relative e.g. like this

//./wwwroot/ts/main.ts

// This doesn't work
//import { MdsPersianCalendar } from 'mds.persian.calendar';

import { MdsPersianCalendar } from '../../node_modules/mds.persian.calendar/mds.persian.calendar';

let calendar = new MdsPersianCalendar();
calendar.now
Sign up to request clarification or add additional context in comments.

1 Comment

Have you changed "import { MdsPersianCalendar } from 'MdsPersianCalendar';" to "import { MdsPersianCalendar } from 'mds.persian.calendar';" ?

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.