question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error [ERR_MODULE_NOT_FOUND] of "dayjs"

See original GitHub issue

Environment

Nuxt CLI v3.0.0-rc.8 20:19:14 RootDir: /Users/user/nuxt-app 20:19:20 Nuxt project info: 20:19:20


  • Operating System: Darwin
  • Node Version: v16.14.2
  • Nuxt Version: 3.0.0-rc.8
  • Package Manager: pnpm@7.9.5
  • Builder: vite
  • User Config: build, meta, alias, plugins, modules, css, routes, vite, ssr
  • Runtime Modules: @nuxtjs/tailwindcss@5.3.2
  • Build Modules: -

👉 Report an issue: https://github.com/nuxt/framework/issues/new 20:19:20

👉 Suggest an improvement: https://github.com/nuxt/framework/discussions/new

👉 Read documentation: https://v3.nuxtjs.org

Reproduction

https://codesandbox.io/s/admiring-night-3gyvfc?file=/nuxt.config.ts

Describe the bug

Aiming to fix the “Hydration completed but contains mismatches” issue, I follow the link upgrade nuxt3 from rc.6 to rc.8.

My repo uses a 3rd party lib “ant-design-vue”: “^3.2.11”

In the reproduction link you will find in the Terminal that an error:

Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/sandbox/node_modules/dayjs/plugin/weekday' imported from /sandbox/.nuxt/dist/server/server.mjs
Did you mean to import dayjs/plugin/weekday.js?
    at new NodeError (internal/errors.js:322:7)
    at finalizeResolution (internal/modules/esm/resolve.js:318:11)
    at moduleResolve (internal/modules/esm/resolve.js:776:10)
    at Loader.defaultResolve [as _resolve] (internal/modules/esm/resolve.js:887:11)
    at Loader.resolve (internal/modules/esm/loader.js:89:40)
    at Loader.getModuleJob (internal/modules/esm/loader.js:242:28)
    at Loader.import (internal/modules/esm/loader.js:177:28)
    at importModuleDynamically (internal/modules/esm/translators.js:114:35)
    at exports.importModuleDynamicallyCallback (internal/process/esm_loader.js:30:14)
    at $id_y5OsMUnGHx (file:///sandbox/.nuxt/dist/server/server.mjs:35032:9) {
  code: 'ERR_MODULE_NOT_FOUND'
}

I tried to add “dayjs” in build.transpile but then I got:

[nuxt] [request error] [unhandled] [500] Cannot read properties of undefined (reading 'extend')
  at $id_YrvcHuiS93 (./.nuxt/dist/server/server.mjs:39591:31)  
  at async __instantiateModule__ (./.nuxt/dist/server/server.mjs:112637:3)

Any solutions? It there no possibility to handle ESM and common js or mjs imports properly? I saw many these kind of issues.

Additional context

The issue “Hydration completed but contains mismatches” mess up my website when I do refresh the page.

So I change from rc.6 to rc.8 aiming to fix the hydration issue but now I encounter in this error.

Logs

No response

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:1
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
arek125commented, Aug 29, 2022
 alias: {
    'dayjs': 'dayjs/esm/'
  },
  build: {
    transpile: [
      "lodash-es",
      "@babel/runtime", // building time: Could not resolve import "@babel/runtime/helpers/esm/objectSpread2.js"
    ]
  },

https://github.com/amihhs/nuxt-ant-vue message component should need to receive incoming style

Thanks, also important line is:

    ssr: {
      noExternal: ['moment', 'compute-scroll-into-view', 'ant-design-vue','dayjs'],
    },
3reactions
amihhscommented, Aug 29, 2022
 alias: {
    'dayjs': 'dayjs/esm/'
  },
  build: {
    transpile: [
      "lodash-es",
      "@babel/runtime", // building time: Could not resolve import "@babel/runtime/helpers/esm/objectSpread2.js"
    ]
  },

https://github.com/amihhs/nuxt-ant-vue message component should need to receive incoming style

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error [ERR_MODULE_NOT_FOUND]: Cannot find module
This answer was the one that helped me! I was using import and the file was .js - Adding --es-module-specifier-resolution=node saved the day...
Read more >
dayjs
Day.js is a minimalist JavaScript library that parses, validates, manipulates, and displays dates and times for modern browsers with a ...
Read more >
Add Latin locale #961
For romcal, I need to add Latin locale to dayjs . Therefore I have some questions regarding this. As Latin weekday names are...
Read more >
Error [ERR_MODULE_NOT_FOUND]: Cannot find module ...
The "Error [ERR_MODULE_NOT_FOUND]: Cannot find module" occurs when you set the type attribute to module in your package.json file, but omit the file...
Read more >
Node.js
To get started with Day.js in your Node.js project, simply add the dependency with NPM.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found