Error resolving module specifier: logrocket, using npm or yarn

615 views Asked by At

I'm trying to initialize LogRocket, using official doc:

  • successfully installed it with node: npm i --save logrocket
  • But when trying to initiate it earlier on my page using
    <script type="module">
        // init LogRocket
        import LogRocket from 'logrocket'
        LogRocket.init("my/project/id")
    </script>

I get this error Uncaught TypeError: Error resolving module specifier: logrocket. Note that I can open the logrocket module by Cmd+click on the from 'logrocket'.

And I can use logrocket for non-npm approach

<script src="https://cdn.lr-ingest.io/LogRocket.min.js" crossorigin="anonymous"></script>
<script>window.LogRocket && window.LogRocket.init('my/project/id');</script>

Does anyone already faced such issue ? How to fix it ?

1

There are 1 answers

0
Hongbo Miao On

I think they at some point changed the way exporting, the doc is out-of-date.

Before I only succeed by using

import * as LogRocket from 'logrocket';

But I just tried again now, both

import * as LogRocket from 'logrocket';
import LogRocket from 'logrocket';

work for me.

Tested on logrocket version 1.0.12