I got an error as if I added this line:
import RNHTMLtoPDF from 'react-native-html-to-pdf';
Error from terminal:
error: bundling failed: Error: Unable to resolve module `react-native-html-to-pdf` from `/B/CreatePDF/App.js`: Module `react-native-html-to-pdf` does not exist in the Haste module map
This might be related to https://github.com/facebook/react-native/issues/4968
To resolve try the following:
1. Clear watchman watches: `watchman watch-del-all`.
2. Delete the `node_modules` folder: `rm -rf node_modules && npm install`.
3. Reset Metro Bundler cache: `rm -rf /tmp/metro-bundler-cache-*` or `npm start -- --reset-cache`.
4. Remove haste cache: `rm -rf /tmp/haste-map-react-native-packager-*`.
at ModuleResolver.resolveDependency (/B/CreatePDF/node_modules/metro/src/node-haste/DependencyGraph/ModuleResolution.js:183:15)
at ResolutionRequest.resolveDependency (/B/CreatePDF/node_modules/metro/src/node-haste/DependencyGraph/ResolutionRequest.js:52:18)
at DependencyGraph.resolveDependency (/B/CreatePDF/node_modules/metro/src/node-haste/DependencyGraph.js:283:16)
at Object.resolve (/B/CreatePDF/node_modules/metro/src/lib/transformHelpers.js:261:42)
at dependencies.map.result (/B/CreatePDF/node_modules/metro/src/DeltaBundler/traverseDependencies.js:399:31)
at Array.map (<anonymous>)
at resolveDependencies (/B/CreatePDF/node_modules/metro/src/DeltaBundler/traverseDependencies.js:396:18)
at /B/CreatePDF/node_modules/metro/src/DeltaBundler/traverseDependencies.js:269:33
at Generator.next (<anonymous>)
at asyncGeneratorStep (/B/CreatePDF/node_modules/metro/src/DeltaBundler/traverseDependencies.js:87:24)
Simulator: (Failed to load bundle ...)
So I installed react-native-html-to-pdf by
npm install react-native-html-to-pdf --save
react-native link react-native-html-to-pdf
The simulator shows the same error, but the log error changed to:
This error is caused by `hasteImpl` returning the same name for different files.
at setModule (/B/CreatePDF/node_modules/jest-haste-map/build/index.js:569:17)
at workerReply (/B/CreatePDF/node_modules/jest-haste-map/build/index.js:641:9)
at processTicksAndRejections (internal/process/task_queues.js:86:5)
(node:6011) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
(node:6011) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
(node:6011) UnhandledPromiseRejectionWarning: Error: jest-haste-map: Haste module naming collision:
Duplicate module name: react-animated
Paths: /B/CreatePDF/node_modules/react-native-html-to-pdf/example/node_modules/react-native/Libraries/Animated/release/package.json collides with /B/CreatePDF/node_modules/react-native/Libraries/Animated/release/package.json
This error is caused by `hasteImpl` returning the same name for different files.
at setModule (/B/CreatePDF/node_modules/jest-haste-map/build/index.js:569:17)
at workerReply (/B/CreatePDF/node_modules/jest-has
I got an error as if I added this line:
import RNHTMLtoPDF from 'react-native-html-to-pdf';
Error from terminal:
Simulator: (Failed to load bundle ...)
So I installed
react-native-html-to-pdf
byThe simulator shows the same error, but the log error changed to:
Loading dependency graph...(node:6011) UnhandledPromiseRejectionWarning: Error: jest-haste-map: Haste module naming collision: Duplicate module name: react-animated Paths: /B/CreatePDF/node_modules/react-native-html-to-pdf/example/node_modules/react-native/Libraries/Animated/release/package.json collides with /B/CreatePDF/node_modules/react-native/Libraries/Animated/release/package.json
Any help? thanks!
EDIT Tried to remove
react-native-html-to-pdf
by:Then error solved. So how to use
react-native-html-to-pdf
together withreact-native-print