Search code examples
javascriptreactjstypescriptreact-nativerequire

Unable to resolve module [external url] within the project or in these directories: node_modules


Im doing a project in react native

I have an object of exercises that include images and videos, everything is fine when the object was created, but when I imported into another file I get this error

undefined Unable to resolve module https://assets.soysuper.fit/cutted+mvp+mp4s/bodyweight_squats.mp4 from /mnt/c/Users/USER/Documents/superfit/app/src/screens/Patient/Workouts/ExercisesList.ts: https://assets.soysuper.fit/cutted+mvp+mp4s/bodyweight_squats.mp4 could not be found within the project or in these directories: node_modules

enter image description here

This is the file of the exercises

enter image description here

And this is the file where I import it, when it happens, the apps automatically crashes with the error message

enter image description here

It would be awesome if someone wcould help me!! thanks in advance


Solution

  • I don't think you need require() for URL, you only need it if the image/video/file is on your local machine.

    so what you need is:

    export const exercises = {
      bodyWeightSquats: {
        ...,
        video: " https://assets.soysuper.fit/cutted+mvp+mp4s/bodyweight_squats.mp4 ",
        image: "https://yourlinktotheimage.com/something.png",
      }