amplitude/Amplitude-TypeScript

SDK Browser not working after following getting started guide

rodriguezmarting opened this issue · 1 comments

Expected Behavior

Following the getting started guide should get me up and running with the browser SDK

Current Behavior

I am following the getting started guide to use the new Typescript Browser SDK.

We have a static site with a small client side app embedded using React and HUGO.

After adding "@amplitude/analytics-browser" using yarn, whenever I try to use it the following error shows up in the browser console: 


localhost/:1 Uncaught TypeError: Failed to resolve module specifier "@amplitude/analytics-browser". Relative references must start with either "/", "./", or "../".

And the following error shows up in the web server console:


'@amplitude/analytics-browser' is imported by lib/analytics.js, but could not be resolved – treating it as an external dependency

The library is indeed installed and I can see the sources in node_modules folder, but for some reason it does not work.

Possible Solution

Steps to Reproduce

  1. run yarn add @amplitude/analytics-browser
    2.initialize the sdk (importing the package using import * as analytics from "@amplitude/analytics-browser"
  2. start the app
  3. encounter the error

Environment

  • JS SDK Version: 2.1.3
  • Installation Method: Yarn
  • Browser and Version: Chrome Version 115.0.57

Hi @rodriguezmarting, did you solve this issue?

I cannot reproduce it without more information. The SDK should work well on a react app and here is an example.
Could you attached your project code to help us debug if you are sill encountering this?