Nuxt.js: Randomly Getting: Cannot find module 'pages/index.js'

Created on 28 Feb 2019  路  36Comments  路  Source: nuxt/nuxt.js

Version

v2.4.5

Reproduction link

https://codesandbox.io/ (Sorry, unable to reproduce it, maybe someone else can)

Steps to reproduce

Unknown but I am not the only one having this issue: https://github.com/nuxt/nuxt.js/issues/5006#issuecomment-468197574

What is expected ?

Server should start normally.

What is actually happening?

I get this error: 'Cannot find module 'pages/index.js' from '/Users/nahtnam/Desktop/programs.nosync/nahtnam/nahtnam''

Additional comments?

The only weird customization I have done is move everything into an src folder. Restarting the server over and over again eventually fixes this issue

Not really sure how to extrac the stack trace but here is a screenshot of the error.

Screen Shot 2019-02-28 at 2.19.48 AM.png
.

This bug report is available on Nuxt community (#c8751)
bug-report pending

Most helpful comment

I'm having the same issue. Ubuntu 18.04 / v2.4.5
It happens after npm run dev, when I navigate to http://localhost:3000/

Workaround is to make a small change in pages/index.vue to trigger regeneration.

All 36 comments

Happens to me as well from time to time.

WebStorm on latest Ubuntu

Same here. Can't see a pattern about whether it happens or not.
v.2.4.5

Same thing happening to me. Sometimes app starts correctly, then an HMR recompile breaks things, other times a fresh start already leads to the error. I have a small project with just 3 pages, a few components and nothing fancy.

Didn't change the project folders structure as @nahtnam did, so the src folder should not be the problem.

Same here i get as well

What OS and IDE are you using guys?

@aldarund VScode on latest OSX

Edit: to make a further test and exclude editor reading/writing/linting during the build I tried quitting VScode and starting nuxt but still have the problem

@aldarund same here: VSCode on latest OSX

@aldarund
PhpShtorm 2018.3
Ubuntu 18.10
node v8.11.4
npm v6.7.0

I am using Ubuntu 16.04, Sublime Text, Node v11.10.0, npm 6.7.0
Same issue

So codeeditor not related . Maybe its happens only on unix subsystem , on win i personally didnt have it even once.. Or maybe there something other related

Is more information required? I can provide a stack trace or something the next time it happens. Please let me know what information you need to help speed this up

I've saw this problem on VSCode/MacOS too

Same issue here, Manjaro with VSCode

I have a problem like this on MacOS 10.14.3 with Node v11.10.1

Same issue. Ubuntu 12.x / Nuxt v.2.4.5.
Running yarn run generate and then yarn run dev is fixing it for me, until it breaks again..

I'm having the same issue. Ubuntu 18.04 / v2.4.5
It happens after npm run dev, when I navigate to http://localhost:3000/

Workaround is to make a small change in pages/index.vue to trigger regeneration.

Same here on mac os / sublime text / Nuxt v2.4.5

same. i have to touch pages/index.vue every time i start the dev server

I had the same issue yesterday, but only once

Any thought what causing this?

Same issue here, running locally in my dev environment. Running touch pages/index.vue does temporarily fix the problem.

Node: 8.15.1 (via Homebrew)
Nuxt: 2.4.5
OS: MacOS Mojave

also getting this issue,

CentOS 7.6.1810
Node: 11.10.1
Nuxt: 2.4.5

For now i'm using touch -acm pages/index.vue && npm run dev.
It looks like some kind of date file change check is broken

@arkhamvm it will not help with HMR (the most annoying part when it's happens right in the middle of problem solving)

just wondering if it could be related to number of inotify watcher. Can you try to increase it and see if it helps or no?
https://github.com/guard/listen/wiki/Increasing-the-amount-of-inotify-watchers#the-technical-details

@aldarund I have this already increased, since Ubuntu have issue with webpack HMR. Also I believe inotify is only Linux related issue, and we have Mac guys here.

ive also had this issue on windows, but only once and could be an irrelivent issue.

i do all my dev on windows which is linked to a drive on my server, on file save the files is uploaded to the server so its nothing todo with file locking or IDE's

ive been trying to narrow down whats cauing this and cant find any link to when it does it and when it works.

just wondering if it could be related to number of inotify watcher. Can you try to increase it and see if it helps or no?
https://github.com/guard/listen/wiki/Increasing-the-amount-of-inotify-watchers#the-technical-details

@aldarund i didnt think this would work, but i raised the limit and same issue persists.

Same issue here, happens completely random (MacOS, PhpStorm, Nuxt 2.4.0)

+2 for me, this problem happens randomly on two distinct environments :
MacOs, PhpStorm, Nuxt 2.4,5
Ubuntu, Visual Studio, Nuxt 2.4.5

NB : Touching /page/index.js after build almost always solves it, but it defeats the "watch" purpose.

@anteriovieira @damienrave
After updating Nuxt to 2.5.1 this issue seems to be vanished.

I confirm too, no more problem since my update in 2.5.1 (about 5 days ago) ! Great!

Same here, Nuxt 2.5.1 and problem gone. Thanks !

been working with the update and have not come into this issue yet 馃檰

Marking this as solved so far. Thanks for pinging back!

Any work on this issue? I have changed the defaults paths and getting this error.

dir: {
  layouts: './client/layouts',
  pages: './client/pages',
  static: './client/static',
  store: './client/store'
}
Was this page helpful?
0 / 5 - 0 ratings

Related issues

bimohxh picture bimohxh  路  3Comments

VincentLoy picture VincentLoy  路  3Comments

vadimsg picture vadimsg  路  3Comments

mikekidder picture mikekidder  路  3Comments

shyamchandranmec picture shyamchandranmec  路  3Comments