0

I have the following structure of folders:

Proyecto

--pruebainventario
----models
------Usuarios.js

--SB
----src
------components
--------screens
----------Register.js

Inside Usuarios.js I have some variables set, which are being exported using module.exports = usuario.

I am trying to retrieve those variables when running node Register.js from Usuarios.js using the following codes:

var usuario = require('./../../../../pruebainventario/models/Usuarios.js')

var usuario = require('../../../../pruebainventario/models/Usuarios.js')

None of them work. What can I do to retrieve the data from the other folder? Please I really need make this. Thanks

GastonKhouri
  • 33
  • 1
  • 7
  • 2
    first require is missing one dot in the begining and both the requires are missing closing single quote, is your code correct? – Tinu Jos K Jan 21 '20 at 12:09
  • Yes, I forgot that when I put the code in the page, I'm following the answer from other question I found. Is this the question https://stackoverflow.com/questions/42163049/node-js-require-from-parent-folder/42163102# But that for some reason don't works for me – GastonKhouri Jan 21 '20 at 12:34
  • Well i know what it would be. But can you share the error you are getting? – Muhammad Zeeshan Jan 21 '20 at 12:42
  • Of curse, this is the error: Unable to resolve "./../../../../pruebainventario/models/Usuarios.js" from "src\components\screens\Register.js" Failed building JavaScript bundle. – GastonKhouri Jan 21 '20 at 13:27

0 Answers0