Steps to reproduce:
react-native init myproject
.cd myproject
.npm install jsdom
.import jsdom from 'jsdom';
.react-native run-ios
.Expected Output: App starts on the React native landing page.
Actual Output:
Unable to resolve module path
from /Users/davidangulo/Desktop/mobile/myproject/node_modules/jsdom/lib/api.js
: Module path
does not exist in the Haste module map
According to their readme: (https://github.com/jsdom/jsdom)
const jsdom = require("jsdom");
const { JSDOM } = jsdom;
That is how you initialize it but unfortunately, it doesn't work.
Hey I had the same problem with jsdom and react-native, jsdom is made for node which would include path, fs and more, but react-native does not have all this.
For me jsdom-jscore did the trick:
import { jsdom } from 'jsdom-jscore-rn'
// ...
const dom = jsdom(html)