nuxt generate 报错,生成dist文件夹中未生成index.html

前提摘要

  1. 构建项目使用官方vue init nuxt-community/starter-template <project-name>方法创建的nuxt项目
  2. 本地开发无问题
  3. npm run build及 npm start部署到now.sh无问题

错误产生

本地执行npm run generate报错:

{ Error: ENOENT: no such file or directory, lstat '/Users/casen/worker/webFile/nuxt/nuxtStarterTest/dist/index.html'
    at Error (native)
  errno: -2,
  code: 'ENOENT',
  syscall: 'lstat',
  path: '/Users/casen/worker/webFile/nuxt/nuxtStarterTest/dist/index.html' }

npm ERR! Darwin 15.3.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "generate"
npm ERR! node v6.10.0
npm ERR! npm  v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! nuxt_starter_test@1.0.0 generate: `nuxt generate`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the nuxt_starter_test@1.0.0 generate script 'nuxt generate'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the nuxt_starter_test package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     nuxt generate
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs nuxt_starter_test
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls nuxt_starter_test
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /Users/casen/worker/webFile/nuxt/nuxtStarterTest/npm-debug.log

且生成文件dist中无index.html

补充说明:原以为是动态路由配置存在问题报错,但将所有动态路由去掉之后还是报相同错误,排除此可能。

求救!!!

阅读 10k
4 个回答

./nuxt.config.js

build: {
  publicPath: '/_nuxt/'
}

这样就好了

你这个问题解决了吗?

我也遇到这个问题,去 GitHub 的 issues 里面也没找到类似的问题,怀疑是新版本更新的 bug

我今天也遇到这个问题了,请问找到解决办法了吗?

大家肯定想不到我的异常原因 /黑脸

我在window上进行开发, 原文件名为 : en_US.json, 修改为 en_us.json 后部署在linux服务器上, 在linux服务器上执行打包操作一直异常 ;

解决办法 : 删除en_us.json 文件, 然后新建一个 en_us.json 文件(而不要重命名);

原因原理可自行google

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题