I want to use the js-cookie library in my TypeScript project.
First, I installed the library and the typings by running npm install js-cookie @types/js-cookie --save-dev
in the directory that contains node_modules
and package.json
. package.json
now contains "@types/js-cookie": "^2.1.0"
and there is a folder js-cookie
in node_modules
.
Then I added
import * as Cookies from "js-cookie";
[...]
Cookies.remove("token");
to my TypeScript file. WebStorm doesn't show any errors.
When I run the server, I get the following error:
fetch.js:32 GET http://localhost:8080/ui/js-cookie 404 (Not Found)
common.js:85 Uncaught (in promise) Error: Fetch error: 404 Not Found
Instantiating http://localhost:8080/ui/js-cookie
Loading http://localhost:8080/ui/src/auth/userStore.tsx
Loading src/app.tsx
at fetch.js:37
at <anonymous>
What exactly did I wrong in importing js-cookie
and how can I fix it?