Steps to reproduce:
react-native init myproject
.cd myproject
.npm install jsdom
.- In my App.js, I added
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: ()
const jsdom = require("jsdom");
const { JSDOM } = jsdom;
That is how you initialize it but unfortunately, it doesn't work.
Steps to reproduce:
react-native init myproject
.cd myproject
.npm install jsdom
.- In my App.js, I added
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./jsdom/jsdom)
const jsdom = require("jsdom");
const { JSDOM } = jsdom;
That is how you initialize it but unfortunately, it doesn't work.
Share Improve this question asked Oct 24, 2018 at 10:27 dcangulodcangulo 2,1072 gold badges24 silver badges55 bronze badges 1-
As far as I know,
jsdom
was made for nodeJS projects and not forreact-native
projects. Insidejsdom/lib/api.js
on line 2, you'll seeconst path = require('path')
and that module is not supported with react native. – Ray Commented Oct 24, 2018 at 13:55
1 Answer
Reset to default 7Hey 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)