Open Samykills opened 6 years ago
@Samykills how do you link the library? You should reference the library within the package.json
in your main app and install it via npm install
. It seems currently it tries to use library from the Desktop and not from the node_modules
folder.
I'm getting the same error. @Samykills, did you manage to solve it?
Maybe it has to be moved to the dependency list.
I had a similar error in the project
Module
dateformatdoes not exist in the Haste module map
and the fix was to explicitly add dateformat
as a dependency. Previously it wasn't and it worked fine.
@maicki ^^^ that's the error I was talking about earlier.
@thorbenprimke Did you add dateformat
to the dependency list of the library or the app you use the lib?
To my app. But this issue was the third in Google results when searching for does not exist in the Haste module map.
So I suppose this error has to do with a dependency missing. Something definitely changed in the tooling because it worked fine in the past.
On Wed, Aug 29, 2018, 8:38 AM Michael Schneider notifications@github.com wrote:
@thorbenprimke https://github.com/thorbenprimke Did you add dateformat to the dependency list of the library or the app you use the lib?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/frostney/react-native-create-library/issues/65#issuecomment-416997830, or mute the thread https://github.com/notifications/unsubscribe-auth/AAtRh_Ndmjb1cI2Lb3RFUyYlsUd53-Ktks5uVrWCgaJpZM4Ulpxi .
got it resolved by using "react-native start --reset-cache", the reference changed from Desktop to node_modules.
fixed by npm add @babel/runtime
Add this command to your terminal >_ npm add @babel/runtime
Problem solved!
What happened with me for this problem,
I encountered this problem twice,
first time i mistakenly imported a js package when it was not installed, it resolved by removing that mistaken import statement
second time i was trying to install 'react-native-modal-overlay' package, and instead of using npm install, i used yarn add react-native-modal-overlay, tried all steps i could find on net, but not resolved, finally, I took a fresh install of repository in another package, -----then also the build failed, t
-- then i ran npm cache clean, ( the result asked to run command 'npm install --cache /tmp/empty-cache' -- i ran this command, and then tried to make build it succeeded
Delete your node_module and run npm install
Similar error said my lib does not exist in the Haste module map. None of above resolve the issue.
as of today, I still have to npm i the package remotely; npm link only works for the native code - once the build completes the javascript doesn't work - I get this error
@evanjmg Do you mean react-native link
? Unfortunately you cannot symlink a react native package via npm link
. This is a problem with the metro bundler and you can follow the issue here: facebook/metro#1
I ran into this same issue.
I inspected the node_modules folder for the custom library, and it looks like the custom library was not copied there properly. Instead, it stores a reference to wherever the library is stored on your computer. For me, it was at a different directory. I think that the npm start server was not able to properly handle copying the referenced folder from the node_modules.
For a workaround, I deleted the reference, created a new directory in node_modules with the same name, then copied all files from where the library exists, to that newly created directory in node_modules. Then it worked.
I'm confused by React-Native's official documentation, specifically:
After [running react-native-create-library] you will navigate into MyLibrary folder and install the npm package to be locally available for your computer by doing:
$ npm install
After this is done you can go to your main react app folder (which you created by doing react-native init MyApp)
- add your newly created module as a dependency in your package.json
- run npm install to bring it along from your local npm repository.
It seems to imply that running npm install
in the newly created library directory that npm will know to look here when instructed to install the package. This did not work for me, and my attempt to install it by directly referencing the file brought me here, as the Haste map did not follow the sym-link.
Are our options really just:
push every change to a remote repo so that it can be downloaded
manually copy the files into the node_modules dir every time
Both of these feel like an unecessary extra step, especially considering what the React-Native docs seem to imply is possible.
what worked for me was to check at the top of your file so that it does not imported something like
import { threadId } from 'worker_threads';
Remove that and it works
I'm confused by React-Native's official documentation, specifically:
After [running react-native-create-library] you will navigate into MyLibrary folder and install the npm package to be locally available for your computer by doing:
$ npm install
After this is done you can go to your main react app folder (which you created by doing react-native init MyApp)
- add your newly created module as a dependency in your package.json
- run npm install to bring it along from your local npm repository.
It seems to imply that running
npm install
in the newly created library directory that npm will know to look here when instructed to install the package. This did not work for me, and my attempt to install it by directly referencing the file brought me here, as the Haste map did not follow the sym-link.Are our options really just:
- push every change to a remote repo so that it can be downloaded
- manually copy the files into the node_modules dir every time
Both of these feel like an unecessary extra step, especially considering what the React-Native docs seem to imply is possible.
Thank you, I think you are correct about the React-Native's doc, npm install
really has nothing to do with making npm package to be locally available.
If nothing work try to update dependencies
in package.json
as
"dependencies": {
"react": "16.3.1",
"react-native": "0.55.4"
...
}
Yep it looks like symlinks are the issue. Having the same problem with importing sibling modules within a Yarn Workspaces mono-repo. I think the solution for now will be to use watchman to manually copy over the sibling module to the consumer's node_modules folder on every change.
i created a library using react-native-create-library named myLib and i have a RN app from react-native-cli named myApp.
The library "myLib" does not contain any native code and only JS code which imports react(basically made a component that i want to be shared), here is the package.json
{ "name": "myLib", "version": "1.0.0", "description": "Set of components to be used throught the app", "main": "index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, "keywords": [ "react-native", "basic-components" ], "author": { "name": "Ullas", }, "license": "", "deprecated": false, "dependencies": { "apisauce": "0.15.2", "react-native-navbar": "2.1.0" }, "peerDependencies": { "react": "16.3.1", "react-native": "0.55.4" } }
when i link this to the RN app "myApp" i get the error :
error: bundling failed: Error: Unable to resolve module
react
from/Users/ullas/Desktop/myLib/index.js
: Modulereact
does not exist in the Haste module map.even though i have react as part of my node_modules for myApp project. How can i run this and use the dependencies provided by the peer project for my library rather then define dependencies of its own and duplicating the same?
need help :(