react-native build error on import
See original GitHub issueI reproduced this from a new npx react-native init reproProj
. Note that android studio, sdk and emulator are prerequisite to the init command and then launching reproProj
with npm run android
.
I’m not too familiar with the build environment for react-native
but anyhow taking the following steps with reproProj
npm i -S --no-optional sanctuary
- add
import * as S from 'sanctuary'
to the generatedApp.js
npm run android
I get:
at ModuleResolver.resolveDependency (D:\src\reproProj\node_modules\metro\src\node-haste\DependencyGraph\ModuleResolution.js:186:15)
at ResolutionRequest.resolveDependency (D:\src\reproProj\node_modules\metro\src\node-haste\DependencyGraph\ResolutionRequest.js:52:18)
at DependencyGraph.resolveDependency (D:\src\reproProj\node_modules\metro\src\node-haste\DependencyGraph.js:287:16)
at Object.resolve (D:\src\reproProj\node_modules\metro\src\lib\transformHelpers.js:267:42)
at D:\src\reproProj\node_modules\metro\src\DeltaBundler\traverseDependencies.js:434:31
at Array.map (<anonymous>)
at resolveDependencies (D:\src\reproProj\node_modules\metro\src\DeltaBundler\traverseDependencies.js:431:18)
at D:\src\reproProj\node_modules\metro\src\DeltaBundler\traverseDependencies.js:275:33
at Generator.next (<anonymous>)
at asyncGeneratorStep (D:\src\reproProj\node_modules\metro\src\DeltaBundler\traverseDependencies.js:87:24)
[Wed Oct 07 2020 19:04:00.925] BUNDLE ./index.js
error: Error: Unable to resolve module `util` from `node_modules\sanctuary-def\index.js`: util could not be found within the project.
The above workflow works fine for other npm libs such as ramda
or redux
.
npx react-native --version
is 4.13.0
metro
: 0.58.0,
metro-core
at 0.58.0,
sanctuary
at 3.1.0
sanctuary-def
at 0.22.0
I’m not familiar with the usage of require
where util
is set up but I gather that it is not specifying that a js file be resolved. Perhaps “metro node-haste” misinterprets the require
usage in a similar way.
Edit - I tried updating metro
to their latest release 0.63.0 but that seems to have broken something in the otherwise as generated app/build.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:6 (3 by maintainers)
Top GitHub Comments
Not at this time! Thanks for your contributions to the development of functional techniques in Javascript!
It’s not clear to me whether there is something I could change to make Sanctuary work better for you, @llaenowyd. Let me know if there is. 😃