I am trying to import the js-search npm package to my client .js
file. Their docs says to write import * as JsSearch from 'js-search';
, however, this gives me a Uncaught TypeError: Failed to resolve module specifier "js-search". Relative references must start with either "/", "./", or "../".
. I tried to configure a relative path for a long time, however I finally figured out that 'js-search'
refers to the package name, not the directory. So, I must be missing some dependency that allows me to use this import line? Thank you.
Edit: directory structure:
myproject
├── myproject
├── node_modules\js-search
└── myapp
├── static\myapp
│ └── myapp.js
└── templates\search
└── index.html
Edit: could it be because I'm running on localhost and not a server?
backend
andfrontend (or client)
directories so make sure you npm install packages in the client directory if they are imported in.js
files from that directory – Orbadiahnpm install --save js-search
and then try it should work – Wollongongwebpack
? – Erland