terrylinla / react-native-sketch-canvas

A React Native component for drawing by touching on both iOS and Android.
MIT License
693 stars 450 forks source link

Issues installing in react-native #74

Open irene-hakes opened 5 years ago

irene-hakes commented 5 years ago

Trying to use this in my native-react app. I get the error:

error: bundling failed: Error: While trying to resolve module @terrylinla/react-native-sketch-canvas from file /[my path]/sampleviro/ViroSample/App.js, the package [my path]/sampleviro/ViroSample/node_modules/@terrylinla/react-native-sketch-canvas/package.json was successfully found. However, this package itself specifies a main module field that could not be resolved ([my path]/sampleviro/ViroSample/node_modules/@terrylinla/react-native-sketch-canvas/index.js. Indeed, none of these files exist:

any ideas what may be causing this?

ShaMan123 commented 5 years ago

yes. I think the problem might be because for some reason the package is downloaded to node_modules under @terrylinla/, causing the config done by react-native link to be wrong. There are 2 options:

1. You could try adding the package directly from github.

Your package.json dependcy should look like this: "@terrylinla/react-native-sketch-canvas": "^0.8.0",

Change it to this: "react-native-sketch-canvas": "github:terrylinla/react-native-sketch-canvas", and run npm install or yarn add

2. Changing native config:

on android change this file settings.gradle:

include ':react-native-sketch-canvas'
project(':react-native-sketch-canvas').projectDir = new File(rootProject.projectDir, '../node_modules/@terrylinla/react-native-sketch-canvas/android')

Haven't worked on ios yet but you should do something equivelant.