3

I am new to Angular2 and TypeScript and I am trying to import Parse into my application. So I have installed parse as a node module using npm install parse --save and I can see the parse folder inside the node_modules folder. Now, in my app.ts file, I am trying the following code but I don't know why is this giving errors.

import {Parse} from 'parse';

It gives the error that it

cannot find the module 'parse'

.

I also tried the following code,

import {} from 'parse'

and it works without errors but I don't know how do I use the Parse object now.

Any help or suggestion is highly appreciated.

Thanks in advance.

2
  • included parse js in html , ryt? Commented Sep 19, 2016 at 20:40
  • No, could you please tell me what should be the path of the src, I have tried ../node_modules/... but not working. Commented Sep 19, 2016 at 20:49

2 Answers 2

5

I had the same problem (Here is it solved). I put the step by step how i solved it here.

  1. Install Parse component to the project

    npm install parse --save
    
  2. Install Parse types

    npm install @types/parse --save
    
  3. import Parse module

    const Parse: any = require('parse');
    
  4. use Parse module

    Parse.initialize("key");
    ...
    

Hope it helps;)

Sign up to request clarification or add additional context in comments.

1 Comment

I had to declare a var in typings.d.ts as => declare var require: any;
1

You need to declare the parse module so that is recognized by typescript.

You can declare the parsemodule yourself with something like this:

declare module 'parse' {
    var parse: any;
    export { parse };
    export default parse;
}

Or you can use the typing definitions provided by Definitely Typed: https://github.com/DefinitelyTyped/tsd

Comments

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.