hapijs / joi

The most powerful data validation library for JS
Other
20.95k stars 1.51k forks source link

Cannot find module '@hapi/hoek/assert' from 'index.js' #2917

Closed sagarpanda closed 1 year ago

sagarpanda commented 1 year ago

Support plan

Context

What are you trying to achieve or the steps to reproduce?

import Joi from "joi";

 const schema = Joi.object({
    items: Joi.array().required(),
    skip: Joi.boolean()
 });

What was the result you got?

    Cannot find module '@hapi/hoek/assert' from 'index.js'
      at Resolver.resolveModule (../../node_modules/jest-resolve/build/index.js:259:17)
      at Object.<anonymous> (../../node_modules/joi/lib/index.js:3:16)

What result did you expect?

This should not throw any error.

Screenshot 2023-02-21 at 1 26 40 PM

priyanshuchauhan commented 1 year ago

@sagarpanda Are you using node v12 ? Updating to node v14 worked for me

Marsup commented 1 year ago

I have reverted everything in 17.8.3 (see https://github.com/hapijs/joi/issues/2914), but indeed expect that for the next major version. You are either using an old node or an old jest.

sagarpanda commented 1 year ago

Thanks @Marsup

lmq352489099 commented 1 year ago
"joi": "^17.9.1"  Is that a problem ?  

  "dependencies": {
    "@bytemd/plugin-gfm": "^1.21.0",
    "@bytemd/plugin-highlight": "^1.21.0",
    "@bytemd/vue-next": "^1.21.0",
    "@iconify/json": "^2.2.44",
    "@pinia-plugin-persistedstate/nuxt": "^1.1.1",
    "@pinia/nuxt": "^0.4.7",
    "ant-design-vue": "^3.2.15",
    "cos-js-sdk-v5": "^1.4.16",
    "cos-nodejs-sdk-v5": "^2.11.19",
    "joi": "^17.9.1",
    "jsonwebtoken": "^9.0.0",
    "less": "^4.1.3",
    "md5": "^2.3.0",
    "moment": "^2.29.4",
    "mysql2": "^3.2.0",
    "pinia": "^2.0.33",
    "qcloud-cos-sts": "^3.1.0",
    "sass": "^1.60.0",
    "unplugin-icons": "^0.16.1",
    "unplugin-vue-components": "^0.24.1",
    "uuid": "^9.0.0"
  }

{
    "url": "/api/auth/login",
    "statusCode": 500,
    "statusMessage": "",
    "message": "Cannot find module 'F:\\project-lmq\\learn-self-study\\bingo-book\\j-book-demo\\.output\\server\\node_modules\\@hapi\\hoek\\lib\\assert' imported from F:\\project-lmq\\learn-self-study\\bingo-book\\j-book-demo\\.output\\server\\chunks\\login.post.mjs\nDid you mean to import @hapi/hoek/lib/assert.js?",
    "stack": ""
}
Marsup commented 1 year ago

It shouldn't be, if you're still having problems, maybe your lockfile is keeping old versions of things, then try to remove and re-add joi.

clopezpro commented 1 year ago
"joi": "^17.9.1"  Is that a problem ?  

  "dependencies": {
    "@bytemd/plugin-gfm": "^1.21.0",
    "@bytemd/plugin-highlight": "^1.21.0",
    "@bytemd/vue-next": "^1.21.0",
    "@iconify/json": "^2.2.44",
    "@pinia-plugin-persistedstate/nuxt": "^1.1.1",
    "@pinia/nuxt": "^0.4.7",
    "ant-design-vue": "^3.2.15",
    "cos-js-sdk-v5": "^1.4.16",
    "cos-nodejs-sdk-v5": "^2.11.19",
    "joi": "^17.9.1",
    "jsonwebtoken": "^9.0.0",
    "less": "^4.1.3",
    "md5": "^2.3.0",
    "moment": "^2.29.4",
    "mysql2": "^3.2.0",
    "pinia": "^2.0.33",
    "qcloud-cos-sts": "^3.1.0",
    "sass": "^1.60.0",
    "unplugin-icons": "^0.16.1",
    "unplugin-vue-components": "^0.24.1",
    "uuid": "^9.0.0"
  }

{
    "url": "/api/auth/login",
    "statusCode": 500,
    "statusMessage": "",
    "message": "Cannot find module 'F:\\project-lmq\\learn-self-study\\bingo-book\\j-book-demo\\.output\\server\\node_modules\\@hapi\\hoek\\lib\\assert' imported from F:\\project-lmq\\learn-self-study\\bingo-book\\j-book-demo\\.output\\server\\chunks\\login.post.mjs\nDid you mean to import @hapi/hoek/lib/assert.js?",
    "stack": ""
}

I HAVE "joi": "^17.9.2", and i have the same problem

image

"Cannot find module 'G:\\cotizador\\.output\\server\\node_modules\\@hapi\\hoek\\lib\\assert' imported from G:\\cotizador\\.output\\server\\chunks\\register.post.mjs\nDid you mean to import @hapi/hoek/lib/assert.js?"

I use Nuxt 3.7.0 with Node.js version: 18.5.0 this is in production

yongjie-zhang-mail commented 1 year ago
"joi": "^17.9.1"  Is that a problem ?  

  "dependencies": {
    "@bytemd/plugin-gfm": "^1.21.0",
    "@bytemd/plugin-highlight": "^1.21.0",
    "@bytemd/vue-next": "^1.21.0",
    "@iconify/json": "^2.2.44",
    "@pinia-plugin-persistedstate/nuxt": "^1.1.1",
    "@pinia/nuxt": "^0.4.7",
    "ant-design-vue": "^3.2.15",
    "cos-js-sdk-v5": "^1.4.16",
    "cos-nodejs-sdk-v5": "^2.11.19",
    "joi": "^17.9.1",
    "jsonwebtoken": "^9.0.0",
    "less": "^4.1.3",
    "md5": "^2.3.0",
    "moment": "^2.29.4",
    "mysql2": "^3.2.0",
    "pinia": "^2.0.33",
    "qcloud-cos-sts": "^3.1.0",
    "sass": "^1.60.0",
    "unplugin-icons": "^0.16.1",
    "unplugin-vue-components": "^0.24.1",
    "uuid": "^9.0.0"
  }

{
    "url": "/api/auth/login",
    "statusCode": 500,
    "statusMessage": "",
    "message": "Cannot find module 'F:\\project-lmq\\learn-self-study\\bingo-book\\j-book-demo\\.output\\server\\node_modules\\@hapi\\hoek\\lib\\assert' imported from F:\\project-lmq\\learn-self-study\\bingo-book\\j-book-demo\\.output\\server\\chunks\\login.post.mjs\nDid you mean to import @hapi/hoek/lib/assert.js?",
    "stack": ""
}

我有,我有同样的问题"joi": "^17.9.2",

图像

"Cannot find module 'G:\\cotizador\\.output\\server\\node_modules\\@hapi\\hoek\\lib\\assert' imported from G:\\cotizador\\.output\\server\\chunks\\register.post.mjs\nDid you mean to import @hapi/hoek/lib/assert.js?"

我将Nuxt 3.7.0与Node一起使用.js版本:18.5.0,这是在生产中

Have you resolved this issue? I'm encountering the same problem with Nuxt 3.7.4, Joi 17.11.0, and Node.js 18.15.0.

clopezpro commented 1 year ago
"joi": "^17.9.1"  Is that a problem ?  

  "dependencies": {
    "@bytemd/plugin-gfm": "^1.21.0",
    "@bytemd/plugin-highlight": "^1.21.0",
    "@bytemd/vue-next": "^1.21.0",
    "@iconify/json": "^2.2.44",
    "@pinia-plugin-persistedstate/nuxt": "^1.1.1",
    "@pinia/nuxt": "^0.4.7",
    "ant-design-vue": "^3.2.15",
    "cos-js-sdk-v5": "^1.4.16",
    "cos-nodejs-sdk-v5": "^2.11.19",
    "joi": "^17.9.1",
    "jsonwebtoken": "^9.0.0",
    "less": "^4.1.3",
    "md5": "^2.3.0",
    "moment": "^2.29.4",
    "mysql2": "^3.2.0",
    "pinia": "^2.0.33",
    "qcloud-cos-sts": "^3.1.0",
    "sass": "^1.60.0",
    "unplugin-icons": "^0.16.1",
    "unplugin-vue-components": "^0.24.1",
    "uuid": "^9.0.0"
  }

{
    "url": "/api/auth/login",
    "statusCode": 500,
    "statusMessage": "",
    "message": "Cannot find module 'F:\\project-lmq\\learn-self-study\\bingo-book\\j-book-demo\\.output\\server\\node_modules\\@hapi\\hoek\\lib\\assert' imported from F:\\project-lmq\\learn-self-study\\bingo-book\\j-book-demo\\.output\\server\\chunks\\login.post.mjs\nDid you mean to import @hapi/hoek/lib/assert.js?",
    "stack": ""
}

我有,我有同样的问题"joi": "^17.9.2", 图像 "Cannot find module 'G:\\cotizador\\.output\\server\\node_modules\\@hapi\\hoek\\lib\\assert' imported from G:\\cotizador\\.output\\server\\chunks\\register.post.mjs\nDid you mean to import @hapi/hoek/lib/assert.js?" 我将Nuxt 3.7.0与Node一起使用.js版本:18.5.0,这是在生产中

Have you resolved this issue? I'm encountering the same problem with Nuxt 3.7.4, Joi 17.11.0, and Node.js 18.15.0.

Yes, I did it with this

https://github.com/nuxt/nuxt/discussions/23065#discussioncomment-6939569