SukkaW / hexo-theme-suka

🎨Modern, powerful and simple theme for Hexo.
https://theme-suka.skk.moe
GNU General Public License v3.0
609 stars 49 forks source link

hexo g 報錯 TypeError: Cannot read property 'XXX' of undefined #113

Closed mosdeo closed 4 years ago

mosdeo commented 4 years ago

I certify that I have first consulted (check with "x")

我确认我已经查看了 (选择时请使用 "x" 取代方括号中的空格)


如果你遇到了运行 hexo g hexo s 时报错

If you get error when you are running hexo s hexo g.

Node.js and NPM Information

Node.js 和 NPM 的相关信息

v12.10.0
6.11.3

Package dependencies Information

依赖包相关信息

# 站點目錄  
{
  "name": "hexo-site",
  "version": "0.0.0",
  "private": true,
  "hexo": {
    "version": "3.9.0"
  },
  "dependencies": {
    "hexo": "^3.9.0",
    "hexo-deployer-git": "^2.0.0",
    "hexo-generator-archive": "^0.1.5",
    "hexo-generator-category": "^0.1.3",
    "hexo-generator-index": "^0.2.1",
    "hexo-generator-tag": "^0.2.0",
    "hexo-renderer-ejs": "^0.3.1",
    "hexo-renderer-marked": "^2.0.0",
    "hexo-renderer-stylus": "^0.3.3",
    "hexo-server": "^0.3.3",
    "json-stringify-safe": "^5.0.1",
    "node-prismjs": "^0.1.2",
    "qr-image": "^3.2.0"
  }
}
# 主題目錄
{
  "name": "hexo-theme-suka",
  "version": "1.3.3",
  "description": "Modern, powerful and simple theme for Hexo",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "setup": "npm cache clean && npm install",
    "lint": "bash lint.sh"
  },
  "repository": {
    "type": "git",
    "url": "git+https://github.com/SukkaW/hexo-theme-suka.git"
  },
  "keywords": [
    "hexo",
    "hexo-theme",
    "suka",
    "sukkaw"
  ],
  "author": "SukkaW",
  "license": "GPL-3.0",
  "bugs": {
    "url": "https://github.com/SukkaW/hexo-theme-suka/issues"
  },
  "homepage": "https://github.com/SukkaW/hexo-theme-suka#readme",
  "devDependencies": {
    "ejs-lint": "0.3.0",
    "eslint": "5.16.0",
    "gulp": "4.0.2",
    "gulp-autoprefixer": "6.1.0",
    "gulp-clean-css": "4.2.0",
    "gulp-rename": "1.4.0",
    "gulp-uglify": "3.0.2",
    "sass-lint": "1.13.1"
  },
  "dependencies": {
    "json-stringify-safe": "5.0.1",
    "node-prismjs": "0.1.2",
    "prismjs": "1.16.0",
    "qr-image": "3.2.0"
  }
}

Hexo version

Hexo 版本号

hexo-cli: 2.0.0
os: Darwin 18.7.0 darwin x64
node: 12.10.0
v8: 7.6.303.29-node.16
uv: 1.31.0
zlib: 1.2.11
brotli: 1.0.7
ares: 1.15.0
modules: 72
nghttp2: 1.39.2
napi: 4
llhttp: 1.1.4
http_parser: 2.8.0
openssl: 1.1.1c
cldr: 35.1
icu: 64.2
tz: 2019a
unicode: 12.1

Hexo & Theme Configuration

站点配置文件和主题配置文件

目錄下的 _config.yml 局部:


# Extensions
## Plugins: https://hexo.io/plugins/
## Themes: https://hexo.io/themes/
theme: suka

主題下的 _config.yml 如同 _config.example.yml 沒修改過。

Error Log

报错日志

$ hexo g --debug
09:18:50.024 DEBUG Writing database to /Users/lky/mosdeo_github_io/db.json
09:18:50.044 DEBUG Hexo version: 3.9.0
09:18:50.045 DEBUG Working directory: ~/mosdeo_github_io/
09:18:50.211 DEBUG Config loaded: ~/mosdeo_github_io/_config.yml
09:18:50.301 DEBUG Plugin loaded: hexo-deployer-git
09:18:50.309 DEBUG Plugin loaded: hexo-generator-index
09:18:50.313 DEBUG Plugin loaded: hexo-generator-tag
09:18:50.316 DEBUG Plugin loaded: hexo-generator-archive
09:18:50.318 DEBUG Plugin loaded: hexo-generator-category
09:18:50.419 DEBUG Plugin loaded: hexo-server
09:18:50.427 DEBUG Plugin loaded: hexo-renderer-ejs
09:18:50.429 DEBUG Plugin loaded: hexo-renderer-stylus
09:18:50.478 DEBUG Plugin loaded: hexo-renderer-marked
09:18:50.822 DEBUG Script loaded: themes/suka/scripts/qrcode/index.js
09:18:50.822 ERROR Script load failed: themes/suka/scripts/prism/index.js
TypeError: Cannot read property 'prism' of undefined
    at /Users/lky/mosdeo_github_io/themes/suka/scripts/prism/index.js:23:37
    at /Users/lky/mosdeo_github_io/node_modules/hexo/lib/hexo/index.js:232:12
    at tryCatcher (/Users/lky/mosdeo_github_io/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/Users/lky/mosdeo_github_io/node_modules/bluebird/js/release/promise.js:517:31)
    at Promise._settlePromise (/Users/lky/mosdeo_github_io/node_modules/bluebird/js/release/promise.js:574:18)
    at Promise._settlePromise0 (/Users/lky/mosdeo_github_io/node_modules/bluebird/js/release/promise.js:619:10)
    at Promise._settlePromises (/Users/lky/mosdeo_github_io/node_modules/bluebird/js/release/promise.js:699:18)
    at Promise._fulfill (/Users/lky/mosdeo_github_io/node_modules/bluebird/js/release/promise.js:643:18)
    at Promise._resolveCallback (/Users/lky/mosdeo_github_io/node_modules/bluebird/js/release/promise.js:437:57)
    at Promise._settlePromiseFromHandler (/Users/lky/mosdeo_github_io/node_modules/bluebird/js/release/promise.js:529:17)
    at Promise._settlePromise (/Users/lky/mosdeo_github_io/node_modules/bluebird/js/release/promise.js:574:18)
    at Promise._settlePromise0 (/Users/lky/mosdeo_github_io/node_modules/bluebird/js/release/promise.js:619:10)
    at Promise._settlePromises (/Users/lky/mosdeo_github_io/node_modules/bluebird/js/release/promise.js:699:18)
    at Promise._fulfill (/Users/lky/mosdeo_github_io/node_modules/bluebird/js/release/promise.js:643:18)
    at /Users/lky/mosdeo_github_io/node_modules/bluebird/js/release/nodeback.js:42:21
    at /Users/lky/mosdeo_github_io/node_modules/graceful-fs/graceful-fs.js:115:16
    at FSReqCallback.readFileAfterClose [as oncomplete] (internal/fs/read_file_context.js:61:3)
09:18:50.823 DEBUG Script loaded: themes/suka/scripts/helper.js
09:18:50.833 DEBUG Script loaded: themes/suka/scripts/search/json_generator.js
09:18:50.834 ERROR Script load failed: themes/suka/scripts/search/index.js
TypeError: Cannot read property 'search' of undefined
    at /Users/lky/mosdeo_github_io/themes/suka/scripts/search/index.js:8:37
    at /Users/lky/mosdeo_github_io/node_modules/hexo/lib/hexo/index.js:232:12
    at tryCatcher (/Users/lky/mosdeo_github_io/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/Users/lky/mosdeo_github_io/node_modules/bluebird/js/release/promise.js:517:31)
    at Promise._settlePromise (/Users/lky/mosdeo_github_io/node_modules/bluebird/js/release/promise.js:574:18)
    at Promise._settlePromise0 (/Users/lky/mosdeo_github_io/node_modules/bluebird/js/release/promise.js:619:10)
    at Promise._settlePromises (/Users/lky/mosdeo_github_io/node_modules/bluebird/js/release/promise.js:699:18)
    at Promise._fulfill (/Users/lky/mosdeo_github_io/node_modules/bluebird/js/release/promise.js:643:18)
    at Promise._resolveCallback (/Users/lky/mosdeo_github_io/node_modules/bluebird/js/release/promise.js:437:57)
    at Promise._settlePromiseFromHandler (/Users/lky/mosdeo_github_io/node_modules/bluebird/js/release/promise.js:529:17)
    at Promise._settlePromise (/Users/lky/mosdeo_github_io/node_modules/bluebird/js/release/promise.js:574:18)
    at Promise._settlePromise0 (/Users/lky/mosdeo_github_io/node_modules/bluebird/js/release/promise.js:619:10)
    at Promise._settlePromises (/Users/lky/mosdeo_github_io/node_modules/bluebird/js/release/promise.js:699:18)
    at Promise._fulfill (/Users/lky/mosdeo_github_io/node_modules/bluebird/js/release/promise.js:643:18)
    at /Users/lky/mosdeo_github_io/node_modules/bluebird/js/release/nodeback.js:42:21
    at /Users/lky/mosdeo_github_io/node_modules/graceful-fs/graceful-fs.js:115:16
    at FSReqCallback.readFileAfterClose [as oncomplete] (internal/fs/read_file_context.js:61:3)
09:18:50.836 DEBUG Loading database.
09:18:51.194 INFO  Start processing

如果你在浏览器中发现了问题

If you find something wrong when visiy your blog in browser.

Which device am I using, such as Android, iOS, Windows, Linux, MacOS

我使用的平台,如 Android、iOS、Windows、Linux、MacOS 等

Which brows am I using, such as Chrome 58.0.3029.110 (64-bit)

我使用的浏览器(如 Chrome 58.0.3029.110 64 位)

Dev Tool - Console.log

开发者面板的控制台日志

What you are expected and what you actually get

预期结果和你的实际结果


Demo site related with this issue, JSFiddle and gist are welcomed.

和 issue 有关的在线演示页面,推荐使用 JSFiddle 和 gist

Link(s) to source code or any usefull link(s)

相关源码或有用资源的入口

SukkaW commented 4 years ago

Have you had the requested dependencies install?

$ cd /path/to/themes/suka
$ npm i
$ cd ../..
mosdeo commented 4 years ago

Have you had the requested dependencies install?

$ cd /path/to/themes/suka
$ npm i
$ cd ../..

是的,我有做這一步。不過是因為出錯,仔細看文件才補做的,就怕有順序相依性。

ysc3839 commented 4 years ago

I think you forget to append additional config to site config. cat themes/suka/site_config.yml >> _config.yml

mosdeo commented 4 years ago

I think you forget to append additional config to site config. cat themes/suka/site_config.yml >> _config.yml

沒錯,補上這一步就成功了!謝謝! 請問是你怎麼從錯誤訊息中看出來的?

ysc3839 commented 4 years ago

@mosdeo https://github.com/SukkaW/hexo-theme-suka/blob/cded12606897228026922311d75086eed6288beb/scripts/search/index.js#L8 这里读的是 hexo site 的 config。