strophe with typescript

230 views
Skip to first unread message

Ahmet Eroglu

unread,
May 22, 2018, 5:56:14 PM5/22/18
to Strophe

Hello I want to use this library in my project, in order to do it, I installed following packages,

npm install --save strophe.js
npm install --save @type/strophe
and then I import the typing with ,
import {Strophe} from "strophe"; in my ts file.
But when I compile my typescript file,I get the followin error.

Error: Cannot find module 'strophe'
at Function.Module._resolveFilename (module.js:547:15)
at Function.Module._load (module.js:474:25)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at Object. (/home/ahmet/Documents/MasterProject/LocationBasedChatApp/out/index.js:3:17)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)

I've been trying to solve this since forever, any help will be greatly appreciated!

Colin Dixon

unread,
Oct 1, 2018, 10:35:03 AM10/1/18
to Strophe
Hello Ahmet

I managed to get it working by doing:

npm install --save strophe.js
npm install --save @types/strophe  (note the spelling here)

Then I went into the node_modules folder and renamed the subfolder in @types from 'strophe' to 'strophe.js'.

Then do 

import { Strophe } from "strophe.js"

I haven't got any code working yet, but the definitions seem to work.
Enter code here...


Reply all
Reply to author
Forward
0 new messages