我正处于学习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中的一个bug,或者是否对在我这一边安装包缺乏理解。任何帮助都将不胜感激,谢谢。
发布于 2020-01-10 22:16:34
终止进程的终端:
ps -ax | grep npm然后,尝试在终端中导航到您的目录,并尝试这样做:
npm I react或者再说一遍:
npm i react-native使用TypeScript和React的简单说明:https://facebook.github.io/react-native/docs/typescript
https://stackoverflow.com/questions/59665426
复制相似问题