首页 > 解决方案 > 我无法安装本机反应

问题描述

我怎样才能解决这个问题 ?当我在 react native 中安装某些东西时,VC 代码显示该错误,这是一个大问题吗?

pm ERR! code E404
npm ERR! 404 Not Found - GET https://registry.npmjs.org/@types%2freact-native-simple-alarm - Not found
npm ERR! 404
npm ERR! 404  '@types/react-native-simple-alarm@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.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\User\AppData\Roaming\npm-cache\_logs\2021-09-21T05_47_59_621Z-debug.log

标签: node.jsreact-nativenpm

解决方案


从那个错误看来,您正在安装 Typescript 声明文件。

@types前缀是 Typescript 的专用类型,它是 typescript 声明文件的存储库(您可以在 distinctlyTyped 中阅读更多内容)。

如果您使用 typescript 编译您的 react-native 代码,那么您应该担心,因为如果您使用的库不支持开箱即用的 typescript,您会看到很多编译问题。你可以选择编写一个专门的 d.ts 来支持它,或者如果你很好,你可以为 @types/ 做出贡献,以便其他人可以使用。:)

简单地说,react-native-simple-alarm 似乎在@types 中没有专门的文件,从源代码来看它也不支持自己的打字稿。如果你跑了

npm install @types/react-native-simple-alarm

你会得到异常,因为@types中不存在该库。

如果您只是使用普通的 javascript,那么下面的命令就足够了。

npm install react-native-simple-alarm //or yarn

推荐阅读