mixpanel-js
mixpanel-js copied to clipboard
unable to load the lib with Angular 2
I've spent the whole day trying to load the module in my Angular 2 app as you describe in your examples/es2015-babelify/
I've tried everything and I keep getting error TS2307: Cannot find module ...
Can you please point me in the right direction?
I found a lot of people with the same issue as Angular 2 is becoming more and more popular. I think a clear guide/readme will help a lot the community.
Thanks!
@agustinhaller are you still having issues with this? AFAIK Typescript doesn't do anything unexpected with module resolution; you should be able to a 2015-style import with:
import mixpanel from 'mixpanel-browser/src/loader-module';
(3,22): error TS2307: Cannot find module 'mixpanel-browser/src/loader-module'.
I got this instead
I am also facing the same issue, did anyone found any solution to this, plz share :)
I just tried this out with the ng2 Hello World app from https://angular.io/docs/ts/latest/cli-quickstart.html and it works out of the box. The code I added to app.component.ts
looks like this:
import mixpanel from 'mixpanel-browser/src/loader-module';
console.log('init mp');
mixpanel.init('FAKE TOKEN');
console.log('init mp succeeded');
From the sounds of it, maybe people on this thread aren't actually installing the mixpanel-browser
library before trying to use it? To install it into node_modules
and add it to your dependencies
entry in package.json
, run the following (inside the same directory as your project's package.json
):
$ npm install --save mixpanel-browser
(I'm not sure if Angular 2 has some special ng
command that does the same thing, but it's just installing a dependency from the NPM package repository.)
The solution above still doesn't work. Angularlytics2 has all of these methods => https://github.com/angulartics/angulartics2
If people would find it helpful, I'll make a sample Hello World that matches the above snippet so you can run it yourselves, but otherwise reports like this last one just don't provide enough information for us to do anything. "Cannot find module" is usually a pretty straightforward installation issue; it's looking for mixpanel-browser
in node_modules
and it isn't there.
@tdumitrescu This works really great. Thank You very much
I am having this same issue ... ive installed both the @types/mixpanel and mixpanel-browser
Still seems to be very difficult to get mixpanel definition file loaded correctly