You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using Tesseract.js in my react-native app, I get the following error:
Unable to resolve module child_process from C:\Projects\ocr-app\node_modules\tesseract.js\src\worker\node\spawnWorker.js: child_process could not be found within the project.
If you are sure the module exists, try these steps:
1. Clear watchman watches: watchman watch-del-all
2. Delete node_modules and run yarn install
3. Reset Metro's cache: yarn start --reset-cache
4. Remove the cache: rm -rf /tmp/metro-*
> 1 | const { fork } = require('child_process');
| ^
2 |
3 | let debugPort = 9229;
4 |
I use Tesseract like this:
import React, { useState, useEffect } from "react";
import { Button, Image, View, Platform, Text } from "react-native";
import * as ImagePicker from "expo-image-picker";
import Tesseract from "tesseract.js";
export default function ImagePickerExample() {
const [image, setImage] = useState(null);
const [text, setText] = useState("");
useEffect(() => {
(async () => {
if (Platform.OS !== "web") {
const { status } = await ImagePicker.requestMediaLibraryPermissionsAsync();
if (status !== "granted") {
alert("Sorry, we need camera roll permissions to make this work!");
}
}
})();
}, []);
const pickImage = async () => {
let result = await ImagePicker.launchImageLibraryAsync({
mediaTypes: ImagePicker.MediaTypeOptions.All,
allowsEditing: true,
aspect: [4, 3],
quality: 1,
});
console.log(result);
if (!result.cancelled) {
setImage(result.uri);
Tesseract.recognize(result.uri, "eng", { logger: (m) => console.log(m) }).then(
({ data: { text } }) => {
setText(text);
}
);
}
};
return (
<View style={{ flex: 1, alignItems: "center", justifyContent: "center" }}>
<Button title="Pick an image from camera roll" onPress={pickImage} />
{image && <Image source={{ uri: image }} style={{ width: 200, height: 200 }} />}
{text && <Text>{text}</Text>}
</View>
);
}
The text was updated successfully, but these errors were encountered:
Closing this issue as the master branch now uses worker_threads rather than child_process (per #630). Therefore, you should not encounter this particular error again. If you encounter a new error, feel free to open a new issue.
When using Tesseract.js in my react-native app, I get the following error:
I use Tesseract like this:
The text was updated successfully, but these errors were encountered: