Installation of @hapi/joi failed to start. Removed Joi 13.x and installed @hapi/joi with yarn add @hapi/joi. Installation finished successfully. However node index.js throws error. yarn remove the module, delete the subdir joi and @hapi/joi under node-modules and reinstall @hapi/joi, the error is the same when launching the project.
```js
const Joi = require('@hapi/joi');
internal/modules/cjs/loader.js:584
throw err;
^
Error: Cannot find module 'joi'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:582:15)
at Function.Module._load (internal/modules/cjs/loader.js:508:25)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:22:18)
at Object.
at Module._compile (internal/modules/cjs/loader.js:701:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
at Module.load (internal/modules/cjs/loader.js:600:32)
at tryModuleLoad (internal/modules/cjs/loader.js:539:12)
at Function.Module._load (internal/modules/cjs/loader.js:531:3)
Should find the Joi module without problem
Other than to remove all deps and clean cache, I don鈥檛 have other advice. It clearly works for everyone else.
Upgraded node to 10.16.0 and the error is the same.
It's likely your code is wrong, the stack trace clearly reads you explicitly require joi in your models/user.js file. I'd look that way.
I am facing the same issue. @emclab How did you resolve it?
I have the same issue
I have the same issue
Just install this types package https://www.npmjs.com/package/@types/hapi__joi
I discovered my issue arose from having installed the most recent nodejs version (13>).
I solved it by updating npm. Run npm install -g npm.
I had the same problem and I found out that i had another dependency that required 'joi' instead of '@hapi/joi'.
I had the same problem and I found out that i had another dependency that required 'joi' instead of '@hapi/joi'.
How to find that "another dependency"? @thirdink
npm ls joi or yarn why joi depending on which you use.
This took me a very long time to debug. In one faraway file I had imported @hapi/Joi (notice the capital J rather than @hapi/joi (lowercase j)
Make sure you are doing require("@hapi/joi") with lowercase letters!
Install it globally... npm i -g @hapi/joi
Yeah no, don't ever do that.
Yeah no, don't ever do that.
Why? I resolved the same issue by doing that.
Because the same version is installed system wide, that's not how you deal with node projects.