Code Monkey home page Code Monkey logo

Comments (20)

Samykills avatar Samykills commented on May 12, 2024 60

got it resolved by using "react-native start --reset-cache", the reference changed from Desktop to node_modules.

from react-native-create-library.

kumarkundan avatar kumarkundan commented on May 12, 2024 41

Delete your node_module and run npm install

from react-native-create-library.

yuanzhanghu avatar yuanzhanghu commented on May 12, 2024 25

Similar error said my lib does not exist in the Haste module map. None of above resolve the issue.

from react-native-create-library.

sovanndyul avatar sovanndyul commented on May 12, 2024 14

fixed by npm add @babel/runtime

from react-native-create-library.

maicki avatar maicki commented on May 12, 2024 9

@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

from react-native-create-library.

miguelHx avatar miguelHx commented on May 12, 2024 2

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.

from react-native-create-library.

techieyann avatar techieyann commented on May 12, 2024 2

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:

  1. push every change to a remote repo so that it can be downloaded

  2. 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.

from react-native-create-library.

petgru avatar petgru commented on May 12, 2024 1

I'm getting the same error. @Samykills, did you manage to solve it?

from react-native-create-library.

thorbenprimke avatar thorbenprimke commented on May 12, 2024 1

Maybe it has to be moved to the dependency list.

I had a similar error in the project

Moduledateformat does 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.

from react-native-create-library.

maicki avatar maicki commented on May 12, 2024

@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.

from react-native-create-library.

thorbenprimke avatar thorbenprimke commented on May 12, 2024

@maicki ^^^ that's the error I was talking about earlier.

from react-native-create-library.

maicki avatar maicki commented on May 12, 2024

@thorbenprimke Did you add dateformat to the dependency list of the library or the app you use the lib?

from react-native-create-library.

thorbenprimke avatar thorbenprimke commented on May 12, 2024

from react-native-create-library.

menrobaer avatar menrobaer commented on May 12, 2024

Add this command to your terminal >_
npm add @babel/runtime

Problem solved!

from react-native-create-library.

akshayjai1 avatar akshayjai1 commented on May 12, 2024

What happened with me for this problem,

I encountered this problem twice,

  1. first time i mistakenly imported a js package when it was not installed, it resolved by removing that mistaken import statement

  2. 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

from react-native-create-library.

evanjmg avatar evanjmg commented on May 12, 2024

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

from react-native-create-library.

CyrusZei avatar CyrusZei commented on May 12, 2024

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

from react-native-create-library.

Jerrywyx avatar Jerrywyx commented on May 12, 2024

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:

  1. push every change to a remote repo so that it can be downloaded
  2. 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.

from react-native-create-library.

aadilmehrajbhat avatar aadilmehrajbhat commented on May 12, 2024

If nothing work try to update dependencies in package.json as

"dependencies": {
     "react": "16.3.1",
     "react-native": "0.55.4"
     ...
}

from react-native-create-library.

jonathanconway avatar jonathanconway commented on May 12, 2024

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.

from react-native-create-library.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.