Anyone got error like this? help me please!
I could not save the listing.
Check your capitalization. The statement to require the package is typically:
const Joi = require(“joi”);
(With a capital J in the object name, small j in the package name.)
And the use when calling the function is Joi.validate (with a capital J)
Dpickut do you have a platform where i could chat you?
Thanks for your help but unfortunately in the tutorial mosh didn’t said anything about joi so I don’t know where to put that.
someone helpppp me
The error being thrown is coming from the validation middleware on the backend – not your JS code on the frontend:
Take a look at the imports and exports in the backend validation.js file – it is in the middleware folder.
I’m just another student trying to help out. As I’ve gone through this and other courses, I share the frustration of being “stuck” on a problem. I hope this helps.
Thank you for always replying to me. I appreciate your help
unfortunately I don’t know anything about back end. can you help me one more time and see what’s wrong here?
ps. I would be glad if we were able to chat each other on a social media platform if you don’t mind … Anyway thank youu again will be waiting for your reply for me to continue learning
Anyone there to
Help, i want to continue my lessons it’s been 2 days now
Sorry, I don’t do social media. I suggest you go back over the part of the course where Mosh sets up the backend server. (Lesson 2, under “Networking”). His code is good (it’s in the backend.zip file that you can download in that lesson).
The error you’re seeing is definitely from node trying to run the backend server via index.js. When it tries to validate what your frontend code is submitting (from the ListingEditScreen.js component), it is throwing the error about Joi.validate not being a function.
The backend consists of node running an instance of Express – a very common backend setup. There are lots of tutorials on this topic. Here are a couple examples: Basic Express Server in Node.js | DigitalOcean
Introduction to Node with Express | GitHub Learning Lab
Is it possible mosh using a different version of node (v12)
and im using the latest (v15)
I never changed the backend.zip by mosh and in the tutorial he was able to make it work but mine im just following him and it didnt work
In my experience, node version incompatibility problems show up when the program is compiled. Your Express server is running, so I don’t think it is a version issue. But, you could try running with the older version of node and see what happens.
And, I checked the backend.zip (Mosh’s code) file that I downloaded back in December. In package.json the “engines” parameter specifies node v12.6.x.
I never changed the backend.zip,
I even copy the source code front end just to make sure i dont have any misspelled codes in the front…
What could possibly go wrong?
Do you think the backend code of mosh uses an old version of joi?
I read some information that joi.validate doesn’t exist anymore and is replaced by schema.validate.
Problem is i dont know how modify or re phrase the code from the backend.zip
Hi jzironman, Did you do >npm install without error in your backend directory prior to running node index.js?
I already fixed the error. the backend zip file of mosh is outdated. Joi has already updated their syntax instead of joi.validate it should be schema.validate. Anyway There is no error already but still cant past the data to the backend hence i dont know anything about node.js
Mosh if you are there please update the backend zip
still can’t read the data.
Jzeff - Keep in mind that you can still use older versions of a package when you’re in the learning mode. I see that the 14.x versions of Joi have been deprecated – but Mosh’s code still runs fine on my machine using joi@14.3.1.
You can load a specific version of a package using the command
yarn add joi@14.3.1
(for example).
This might throw some package compatibility warnings, but it should still run.
Note: I wouldn’t use
expo install joi@14.3.1
for this purpose because expo install looks for the latest version of a package that is compatible with your version of Expo. That might result in installation of the 17.x version of joi, which is not compatible with Mosh’s code in the backend.zip file.
Dave
ohh I think this make sense!
Do you know how to modify the expo package to version 17?
still not working.
Extracted again the backend zip and use
npm i
yarn add joi v 14
node index.js
still cant read the files, and got the first error that i have fixed already “Joi is not a function”
I fix that using schema.validate its indicated on the documentation for joi.
but other incompatible/ outdated codes I cant figured out anymore since im not good with node.js , im learning react native not node