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: ENOENT: no such file or directory in Vue CLI 3

See original GitHub issue

I’m getting the following error when trying to build:

Building for production...Error: ENOENT: no such file or directory, stat '/Users/me/Code/project/index.html'

Package: "prerender-spa-plugin": "^3.1.0"

File: vue.config.js:

const PrerenderSPAPlugin = require('prerender-spa-plugin');

const Renderer = PrerenderSPAPlugin.PuppeteerRenderer;
const path = require('path');

module.exports = {
  configureWebpack: config => {
    if (process.env.NODE_ENV !== 'production') return;

    return {
      plugins: [
        new PrerenderSPAPlugin({
          staticDir: path.join(__dirname),
          routes: ['/'],
          minify: {
            collapseBooleanAttributes: true,
            collapseWhitespace: true,
            decodeEntities: true,
            keepClosingSlash: true,
            sortAttributes: true,
          },
          renderer: new Renderer({
            renderAfterDocumentEvent: 'render-event',
          }),
        }),
      ],
    };
  },
};

I don’t have any routes, only a single index.html page.

Also, when I run yarn build and get that error, I try to kill the process in terminal but it keeps returning Building for production... without anything happening, and I have to quit terminal for it to stop.

Edit: I’ve also tried adding staticDir: path.join(__dirname, './public') but the build hangs without any errors.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:9

github_iconTop GitHub Comments

4reactions
JoshTheDerfcommented, May 17, 2018

That might be your issue then, the plugin is waiting for your app to fire a DOM event, so if your app isn’t doing that, it will hang.

The most basic solution would be to replace renderAfterDocumentEvent: 'render-event' with renderAfterTime: 5000 or something like that. Not ideal, but should get you started.

1reaction
manuelgeekcommented, Dec 16, 2020

@JoshTheDerf thanks, for me, i had to add data-server-rendered="true" in my <div id="app" data-server-rendered="true"></div> and

renderer: new Renderer({
   renderAfterElementExists: '#app',
}),
Read more comments on GitHub >

github_iconTop Results From Across the Web

How to fix error " No such file or directory error" with vue-cli ...
I mean, after install vue-cli with npm i -g @vue/cli restart the terminal or update the source with something like: source ~/.bash_profile ...
Read more >
Vue CLI project setup throws ENOENT: no such file or ...
I am trying to create a new Vue.js app and I am running the command: vue create client. Next I am selecting the...
Read more >
How to fix error " No such file or directory error" with vue-cli ...
I mean, after install vue-cli with npm i -g @vue/cli restart the terminal or update the source with something like: source ~/.bash_profile (or...
Read more >
Why is Vue 2.6 the default install when I do Npm Install?
As I am new to Vue, I am thinking why spend time with V2.3 tutorials when the V3.0 tuts ... Module build failed:...
Read more >
vue/cli启动异常:ENOENT: no such file or directory, scandir
VueCli 启动报错:ENOENT: no such file or directory, scandir 'D:\Data\Project\VueProject\hello\node_modules\@vue\cli-plugin-eslint\locales'
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