Having some trouble importing the js-search npm package into my client-side .js
file. The documentation suggests using
import * as JsSearch from 'js-search';
, but I keep getting a Uncaught TypeError: Failed to resolve module specifier "js-search". Relative references must start with either "/", "./", or "../".
. After trying different relative paths, I realized that 'js-search'
actually refers to the package name and not the directory. Is there a missing dependency that I need to include in order to use this import statement? Thank you.
Edit: project directory structure:
myproject
├── myproject
├── node_modules\js-search
└── myapp
├── static\myapp
│ └── myapp.js
└── templates\search
└── index.html
Edit: Could it be related to running on localhost rather than a server?