我想在我的 TypeScript 项目中使用js-cookie库。
npm install js-cookie @types/js-cookie --save-dev
首先,我通过在包含node_modules
和的目录中运行来安装库和类型package.json
。package.json
现在包含并且."@types/js-cookie": "^2.1.0"
中有一个文件夹js-cookie
。node_modules
然后我加了
import * as Cookies from "js-cookie";
[...]
Cookies.remove("token");
到我的 TypeScript 文件。WebStorm 没有显示任何错误。
当我运行服务器时,我收到以下错误:
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>
我在导入时到底做错了什么,我js-cookie
该如何解决?