Nuxt.js: nuxt generate error, rc11

Created on 24 Oct 2017  路  5Comments  路  Source: nuxt/nuxt.js

Error: ENOENT: no such file or directory, lstat 'path_to_my_project/dist/index.html'

generate config in nuxt.config.js :
generate: {
routes: [
'/login'
]
}

This question is available on Nuxt.js community (#c1732)
help-wanted

Most helpful comment

Figured it out! This happens when you have the nuxtServerInit method in your store actions. This can only be done when running as a server so it means generation cannot be done. If you have this then you will get the above error when trying. So either delete that function or run in on node with npm run build and start :)

All 5 comments

Hi @huanyu,
can you explain more about your issue?

@alexchopin I try to use generate command to transform my app into static site. According to the document, i add a generate property in nuxt.config.js, like i said above. After that, i run "nuxt generate", then got that error, and there are no html file in directory 'dist' generated.

generate: { routes: [ '/', '/login' ] }

console output are:
`hbdeMacBook-Pro:trunk.cloud.platform hb$ npm run generate

cloud.[email protected] generate /Users/hb/Documents/work/haimian.front/trunk.cloud.platform
nuxt generate

nuxt:generate Generating... +0ms
nuxt:build App root: /Users/hb/Documents/work/haimian.front/trunk.cloud.platform +0ms
nuxt:build Generating /Users/hb/Documents/work/haimian.front/trunk.cloud.platform/.nuxt files... +1ms
nuxt:build Generating files... +10ms
nuxt:build Generating routes... +8ms
nuxt:build Building files... +31ms
Build completed in 20.342s

Hash: 76e5c6fe650f81dab180
Version: webpack 3.7.1
Time: 20348ms
Asset Size Chunks Chunk Names
pages/index.c04279fd5a7a0adee546.js 34 kB 0 [emitted] pages/index
img/sidebg.9ecc86d.png 43.6 kB [emitted]
img/bg4.7543e04.jpg 107 kB [emitted]
img/empty.b74af1e.png 7.41 kB [emitted]
img/bg2.e1b7061.jpg 96.1 kB [emitted]
img/icons.23c77e2.png 4.91 kB [emitted]
img/fail.be72c9a.png 8.35 kB [emitted]
img/radio-selected.a1de6bd.png 1.19 kB [emitted]
img/bg1.5320e81.jpg 85.9 kB [emitted]
img/bg7.1737b59.jpg 121 kB [emitted]
img/bg3.bd33f6b.jpg 54.6 kB [emitted]
img/bg6.b6e7d0a.jpg 60.2 kB [emitted]
img/login_bg.52e31df.png 181 kB [emitted]
img/building.7547ee7.gif 51.6 kB [emitted]
img/radio.f19828b.png 1.13 kB [emitted]
img/house.d30dbe1.png 9.71 kB [emitted]
img/bg5.5439186.jpg 45.1 kB [emitted]
pages/create/index.15744b0b750b2382e81c.js 40.3 kB 1, 6 [emitted] pages/create/index
pages/register/index.b92fcacd1cc46dfc0cc9.js 81.2 kB 2 [emitted] pages/register/index
pages/forget/index.b634de6e21837ca8ceee.js 80.1 kB 3 [emitted] pages/forget/index
pages/createsuccess/index.cdb826f824532f859e39.js 31.8 kB 4 [emitted] pages/createsuccess/index
pages/login/index.72c2dbaf48638439d1b6.js 35.1 kB 5 [emitted] pages/login/index
pages/create/CateSelect.077fc5679af3c8b84753.js 28.1 kB 6 [emitted] pages/create/CateSelect
pages/processing/index.baab0d8078346476f3db.js 3.95 kB 7 [emitted] pages/processing/index
pages/myshop/index.63c7846d5a2d2f0c801c.js 3.86 kB 8 [emitted] pages/myshop/index
pages/createfail/index.2b36db447c5024c872a9.js 3.98 kB 9 [emitted] pages/createfail/index
pages/protocal/index.dfbd566febf0d7a5fce1.js 3.8 kB 10 [emitted] pages/protocal/index
layouts/default.5c0cb4d9768910dc67ff.js 46.3 kB 11 [emitted] layouts/default
app.e987acbd0e424e2448e9.js 81.4 kB 12 [emitted] app
common.a9d45fff725bdcc9ddc8.js 104 kB 13 [emitted] common
14.f33f077c4d94d717070e.js 71.5 kB 14 [emitted]
manifest.76e5c6fe650f81dab180.js 2.13 kB 15 [emitted] manifest
LICENSES 1.6 kB [emitted]

  • 19 hidden assets
    Hash: 57a682c30f37426834d6
    Version: webpack 3.7.1
    Time: 3626ms
    Asset Size Chunks Chunk Names
    server-bundle.json 1.48 MB [emitted]
    nuxt:generate Destination folder cleaned +0ms
    nuxt:generate Static & build files copied +95ms
    Generating routes
    nuxt:render Rendering url / +0ms
    nuxt:render Rendering url /createfail +68ms
    nuxt:render Rendering url /register +3ms
    nuxt:render Rendering url /processing +2ms
    nuxt:render Rendering url /login +1ms
    nuxt:render Rendering url /forget +3ms
    nuxt:render Rendering url /protocal +2ms
    nuxt:render Rendering url /create +1ms
    nuxt:render Rendering url /createsuccess +4ms
    nuxt:render Rendering url /myshop +2ms
    nuxt:render Rendering url /create/CateSelect +1ms
    { Error: ENOENT: no such file or directory, lstat '/Users/hb/Documents/work/haimian.front/trunk.cloud.platform/dist/index.html'
    errno: -2,
    code: 'ENOENT',
    syscall: 'lstat',
    path: '/Users/hb/Documents/work/haimian.front/trunk.cloud.platform/dist/index.html' }
    npm ERR! code ELIFECYCLE
    npm ERR! errno 1
    npm ERR! cloud.[email protected] generate: nuxt generate
    npm ERR! Exit status 1
    npm ERR!
    npm ERR! Failed at the cloud.[email protected] generate script.
    npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! /Users/hb/.npm/_logs/2017-10-26T01_28_46_795Z-debug.log
`

+1

Figured it out! This happens when you have the nuxtServerInit method in your store actions. This can only be done when running as a server so it means generation cannot be done. If you have this then you will get the above error when trying. So either delete that function or run in on node with npm run build and start :)

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings