如何解决-无法找到模块'@ okta / okta-react'的声明文件-错误?

问题描述

我在应用程序中安装了@okta/okta-react软件包,但引发了以下错误

Could not find a declaration file for module '@okta/okta-react'.
'.../node_modules/@okta/okta-react/dist/index.js' implicitly has an 'any' type.
Try `npm install @types/okta__okta-react` if it exists or add a new declaration (.d.ts)
file containing `declare module '@okta/okta-react';`ts(7016)

如何解决错误

我尝试了什么?

我检查了此blog。我尝试实现此解决方案,但我的应用程序没有tsconfig.json。

编辑1:

我尝试安装@types/okta__okta-react,但收到此错误

$ npm install @types/okta__okta-react
npm ERR! code E404
npm ERR! 404 Not Found - GET https://registry.npmjs.org/@types%2fokta__okta-react - Not found
npm ERR! 404 
npm ERR! 404  '@types/okta__okta-react@latest' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
npm ERR! 404
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball,folder,http url,or git url.

解决方法

似乎它们还没有类型。您需要在https://github.com/okta/okta-oidc-js/issues/66#issuecomment-394574326

处遵循开发人员的建议 ,

更改节点版本

就我而言,在更改节点版本后得到了解决 [Module not found: Can't resolve] 错误。 以前的版本 = v12.4.0 更新至 = v15.8.0

尝试 nvm use 15.8.0(在终端中)