0

I am in my initial stages of learning react and have a limited understanding of npm manager and importing libraries into project. For my current project, I had installed react-native using

npm install react-native

This also reflects in my package.json and node_modules folder

"react-native": "^0.61.5"

Now, when I try to import react-native as follows into AppCarousel.js

import React from 'react';
import {Dimensions} from 'react-native';

and then build the application , i get the following error message

.\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

I tried referring to the the following questions i) link1 ii)link2

I cannot make out if this is a bug in npm or if there is a lack of understanding for installing packages on my side. Any help will be appreciated, thanks.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
95_96
  • 341
  • 2
  • 12
  • Which else commands have ran at the time of installation? – Karan Mehta Jan 09 '20 at 13:58
  • @KaranMehta i did install other libraries using npm . For react-native, i only ran npm install react-native and also as the other answers suggested in the link, i tried installing react-native-cli as well using npm again, but that didn't solve my problem – 95_96 Jan 09 '20 at 14:04

1 Answers1

0

Terminal to kill the process:

ps -ax | grep npm

Then try to navigate to your directory in your terminal and try to do write this:

npm I react

or again:

npm i react-native

Simple explanation to get in use with TypeScript and React: https://facebook.github.io/react-native/docs/typescript

Max
  • 183
  • 1
  • 5
  • 18