45

i have started a new react-native project and after that i installed react-native-maps i can't run react-native run-android because the terminal displays the following error:

module.js:550
    throw err;
    ^

Error: Cannot find module 'asap/raw'
    at Function.Module._resolveFilename (module.js:548:15)
    at Function.Module._load (module.js:475:25)
    at Module.require (module.js:597:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/home/valentino/Scrivania/lolo/node_modules/promise/lib/core.js:3:12)
    at Module._compile (module.js:653:30)
    at Module._compile (/home/valentino/Scrivania/lolo/node_modules/pirates/lib/index.js:83:24)
    at Module._extensions..js (module.js:664:10)
    at Object.newLoader [as .js] (/home/valentino/Scrivania/lolo/node_modules/pirates/lib/index.js:88:7)
    at Module.load (module.js:566:32)

The message is shown if i install react-native-maps, this is the command with i have built the project with:

react-native init appName
cd appName
npm install react-native-maps --save
react-native run-android

How I can resolve this problem?

Am I doing something wrong?

Thanks for the help.

Luke Walker
  • 511
  • 5
  • 19
V.Cozzatella
  • 709
  • 2
  • 9
  • 15

4 Answers4

88

Running npm install in your project directory usually works.

(What it does is that it installs all the dependencies in the local node_modules folder that may have been downloaded when you installed that one package.)

SSBakh
  • 1,487
  • 1
  • 14
  • 27
  • By "project directory" do you mean inside the ios/android folder or the main folder of the React-Native project which contains ios and android folders? – nr5 Jan 07 '19 at 18:45
  • @nr5 the latter (aka the main folder) – SSBakh Jan 10 '19 at 14:45
8

Running npm install did not solve the problem for me.

I ran npm install -g asap to install asap and then the error went away.

technoplato
  • 3,293
  • 21
  • 33
7

The react-native init command creates a project which uses yarn by default since 0.57 (has yarn.lock). I had the same error when I installed a plugin by npm install, so the conclusion is that you can't use both package manager for the same project at the same time (yarn and npm). So:

  • Use yarn add instead of npm install.
  • Or if you don't want to use yarn, then "switch" to npm by running npm install first (after this you can delete yarn.lock and you must always use npm from this point instead of yarn).
slaci
  • 111
  • 4
1

Deleting node_modules and reinstalling didn't fix but doing npm install asap in the project directory fixed my issue.

m9m9m
  • 1,655
  • 3
  • 21
  • 41