Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ERROR in ./.nuxt/date-fns.js #17

Closed
desiboli opened this issue Oct 3, 2019 · 14 comments
Closed

ERROR in ./.nuxt/date-fns.js #17

desiboli opened this issue Oct 3, 2019 · 14 comments

Comments

@desiboli
Copy link

desiboli commented Oct 3, 2019

Hi! after upgrading to version 1.0.0 I get this error in Nuxt build.

ERROR in ./.nuxt/date-fns.js
Module not found: Error: Can't resolve 'date-fns/locale' in '.nuxt'
 @ ./.nuxt/date-fns.js 14:0-37 61:18-20
 @ ./.nuxt/index.js
 @ ./.nuxt/client.js
 @ multi ./.nuxt/client.js

 FATAL  Nuxt build error

Nuxt version: 2.10.0

@ricardogobbosouza
Copy link
Member

ricardogobbosouza commented Oct 4, 2019

@desiboli Try re-install dependencies:

rm -rf node_modules yarn.lock && yarn

If it doesn't work, could you provide a repository?

@Diglio
Copy link

Diglio commented Oct 4, 2019

Getting the same error on a fresh install of this package on a fresh nuxt project.

@ricardogobbosouza
Copy link
Member

@Diglio Please provide a repository and step by step to reproduce

@ricardogobbosouza
Copy link
Member

ricardogobbosouza commented Oct 4, 2019

It works for me.
Try this:

  1. Create this files
// pages/index.vue
<template>
  <div>
    {{ $dateFns.format(new Date()) }}
  </div>
</template>
// package.json
{
  "private": true,
  "scripts": {
    "dev": "nuxt"
  },
  "dependencies": {
    "nuxt": "^2.10.0"
  },
  "devDependencies": {
    "@nuxtjs/date-fns": "^1.0.0"
  }
}
// nuxt.config.js
export default {
  buildModules: [
    '@nuxtjs/date-fns'
  ],
  dateFns: {
    format: 'yyyy-MM-dd'
  }
}
  1. Run yarn
  2. Run yarn dev

@desiboli
Copy link
Author

desiboli commented Oct 4, 2019

Ok I was trying to reproduce this issue in a fresh Nuxtjs project using Nuxt cli (npx).
I created a SPA app and stumbled into another issue that blocked me from reproducing this reported issue with date-fns/locale.

This is the issue nuxt/nuxt#6500

You can reproduce this issue in this repo: https://github.com/desiboli/nuxt-error

I however could not reproduce the date-fns issue in a Universal nuxt app. That was working fine!

NOTE: that I'm using NPM not Yarn!

In my current project I still couldn't fix the error, I did the following steps:

  1. Deletet node_modules

  2. Added buildModules: [ '@nuxtjs/date-fns' ], dateFns: { format: 'yyyy-MM-dd' } and removed the module from
    modules: [ ]

  3. I also moved the package from dependencies to devDependencies.

  4. npm install

  5. npm run build

  6. Same error! :-(

@ricardogobbosouza
Copy link
Member

ricardogobbosouza commented Oct 7, 2019

@desiboli It's a problem with nuxt v2.10.0 😞

@chidindu-ogbonna
Copy link

Installing date-fns solves the issue.

The generated files from the build depend on date-fns.

@ricardogobbosouza
Copy link
Member

@desiboli update nuxt to v2.10.1

Does this still occur?

@desiboli
Copy link
Author

desiboli commented Oct 12, 2019

@ricardogobbosouza yes unfortunately this still occurs!
I have still not tested @6ones solution by installing the date-fns package, but it should not be necessary right ?

So I did the following before trying out the "npm run build" again where the issue occurs.

  1. Removed node_modules
  2. Removed package-lock.json file
  3. Removed .nuxt file
  4. npm cache clean
  5. npm install
  6. npm run build
  7. Error:
ERROR in ./.nuxt/date-fns.js
Module not found: Error: Can't resolve 'date-fns/locale' in '/Users/musse/Sites/plucktv/.nuxt'
Nuxt version: "nuxt": "2.10.1",
Nuxt/date-fns version: "@nuxtjs/date-fns": "1.0.0", 
Nuxt.config.js settings:
mode: 'spa'
  modules: [
    '@nuxtjs/pwa',
    '@nuxtjs/axios',
    '@nuxtjs/style-resources',
    '@nuxtjs/bulma',
    'nuxt-device-detect'
  ],
  styleResources: {
    scss: [
      '~assets/scss/styles.scss'
    ]
  },
  buildModules: [
    ['@nuxtjs/date-fns']
  ],
  dateFns: {
    locales: ['sv'],
    defaultLocale: 'sv',
    format: 'yyyy-MM-dd'
  },

@ricardogobbosouza
Copy link
Member

@desiboli I still can't reproduce this issue
Please check the version of date-fns

@ricardogobbosouza
Copy link
Member

If the problem persists, please reopen

@pancake-boy
Copy link

still an issue on a fresh install

@ricardogobbosouza
Copy link
Member

@desiboli , @pancake-boy
I still can't reproduce this issue
Please provide a repository to reproduce

@mikehoh
Copy link

mikehoh commented Feb 17, 2020

Probably you have installed date-fns globally that's why you don't see this error.

As said @6ones Installing date-fns solves the issue.
Just npm install date-fns --save and it'll work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants