
[英]My react-native application is unable to launch on android after installing a package containing native code
[英]react-native:Unable to import react-native after installing through npm
我正处于学习 React 的初始阶段,对 npm 管理器和将库导入项目的理解有限。 对于我当前的项目,我使用安装了 react-native
npm install react-native
这也反映在我的 package.json 和 node_modules 文件夹中
"react-native": "^0.61.5"
现在,当我尝试将 react-native 如下导入 AppCarousel.js 时
import React from 'react';
import {Dimensions} from 'react-native';
然后构建应用程序,我收到以下错误消息
.\src\Components\AppCarousel.js
Cannot find module: 'react-native'. Make sure this package is installed.
You can install this package by running: npm install react-native.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! react@1.0.0 build: `react-scripts build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the react@1.0.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\{USER}\AppData\Roaming\npm-cache\_logs\2020-01-09T13_08_54_364Z-debug.log
The terminal process terminated with exit code: 1
我无法确定这是 npm 中的错误还是我对安装软件包缺乏了解。 任何帮助将不胜感激,谢谢。
终止进程的终端:
ps -ax | grep npm
然后尝试导航到终端中的目录并尝试编写以下内容:
npm I react
或再次:
npm i react-native
使用 TypeScript 和 React 的简单解释: https : //facebook.github.io/react-native/docs/typescript
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.