GithubHelp home page GithubHelp logo

首页显示“500 啊哦”错误 about candy HOT 15 OPEN

guo-yu avatar guo-yu commented on September 25, 2024
首页显示“500 啊哦”错误

from candy.

Comments (15)

guo-yu avatar guo-yu commented on September 25, 2024

theme not found 具体显示的错误是什么呢?可以在本地运行的时候在日志上看到错误堆栈

from candy.

harrylu101 avatar harrylu101 commented on September 25, 2024

遇到了同样的错误:

Error: template not found
at Theme.render (/home/f1mobi/candy/node_modules/theme/libs/theme.js:68:42)
at /home/f1mobi/candy/routes/page.js:40:17
at Promise. (/home/f1mobi/candy/ctrlers/thread.js:54:11)
at Promise. (/home/f1mobi/candy/node_modules/express-scaffold/node_modules/mongoose/node_modules/mpromise/lib/promise.js:177:8)
at Promise.EventEmitter.emit (events.js:95:17)
at Promise.emit (/home/f1mobi/candy/node_modules/express-scaffold/node_modules/mongoose/node_modules/mpromise/lib/promise.js:84:38)
at Promise.fulfill (/home/f1mobi/candy/node_modules/express-scaffold/node_modules/mongoose/node_modules/mpromise/lib/promise.js:97:20)
at Promise.resolve (/home/f1mobi/candy/node_modules/express-scaffold/node_modules/mongoose/lib/promise.js:108:15)
at Promise. (/home/f1mobi/candy/node_modules/express-scaffold/node_modules/mongoose/node_modules/mpromise/lib/promise.js:177:8)
at Promise.EventEmitter.emit (events.js:95:17)
GET / 500 575ms
GET /candy-theme-flat/images/favicon.ico 304 11ms
GET /candy-theme-flat/stylesheets/duoshuo.css 304 17ms
GET /candy-theme-flat/stylesheets/style.css 200 228ms
GET /candy-theme-flat/stylesheets/bootstrap.min.css 304 7ms
GET /candy-theme-flat/stylesheets/font-awesome.min.css 304 6ms
GET /candy-theme-flat/images/bg.png 304 9ms
GET /candy-theme-flat/images/logo.png 304 13ms
GET /candy-theme-flat/images/candy-mini.png 304 9ms

没有写过node程序 配置的时候遇到好些问题。只好发一个评论问问了。

from candy.

harrylu101 avatar harrylu101 commented on September 25, 2024

我在控制台打了log:

Theme.prototype.render = function(template, data, callback) {
// 先判断是不是有效的文件名
var pkgname = hub.finder.split(template);
var filename = hub.finder.split(template, 'filename');
console.log('template:' + template);
console.log('pkgname:' + pkgname);
console.log('filename:' + filename);
var cb = (callback && .isFunction(callback)) ? callback : function(){};
if (!pkgname || !filename) return cb(new Error('template not found'));
// 判断是不是 shortname, 这里有一个硬编码,需要把这个功能放到 pkghub 中
if (pkgname.indexOf('-') === -1 && this.meta.name) pkgname = this.meta.name + '-theme-' + pkgname;
// 混合 locals,替代 app.locals 与 res.locals
if (!
.isEmpty(this.locals)) data = _.extend(this.locals, data);
return render([pkgname, filename].join('/'), data, cb);
};

输出结果是这样的:
template:/index
pkgname:
filename:index

看起来是无法定位pkgname。

from candy.

guo-yu avatar guo-yu commented on September 25, 2024

@harrylu 这个是 clone 仓库的最新版本还是使用 npm 安装的版本呢?看这个错误日志是你运行的时候找不到首页的 template 了,需要更多的信息才能确定是什么问题。另外,因为 theme 模块中没有暴露具体错误,所以这个错误也可能是渲染模板的时候报错引起的,这个问题会在 theme 的下一个版本中的到解决。所以可能不一定是模板找不到,也可能是模板渲染中出现错误

from candy.

guo-yu avatar guo-yu commented on September 25, 2024

哦我知道是什么问题了,仓库里的不稳定版本依赖了一个没有发布的 0.0.7 theme 版本,我刚发布了 theme 0.0.7 然后你再 npm install theme 一下就好了。

from candy.

harrylu101 avatar harrylu101 commented on September 25, 2024

谢谢这么晚还回复:-)

  1. 是git clone的仓库
  2. 看起来是这样,但是没有更多信息了。具体的log在我上一个comment里。别的没有了。

好的,我马上测试。

from candy.

harrylu101 avatar harrylu101 commented on September 25, 2024

It works. 谢谢你哎!

from candy.

guo-yu avatar guo-yu commented on September 25, 2024

@harrylu 把 candy 的 theme 依赖升级到 0.0.7 应该就没问题了,因为我周末的时候给 candy 加了一个默认主题的配置,然后把渲染逻辑里的硬编码删掉了,所以你那才会找不到模板。

from candy.

harrylu101 avatar harrylu101 commented on September 25, 2024

@turingou 已经可以了。这个项目很棒。赶紧睡觉吧,期待candy变得更好用。我是android开发者,否则就一起出力了。

from candy.

hudidit avatar hudidit commented on September 25, 2024

我在 /root/.pm2/logs/app-err-1.log 里看到的是:Error: Cannot find module 'npm',重复出现了很多次。

from candy.

harrylu101 avatar harrylu101 commented on September 25, 2024

@hudidit 这是一个很常见的问题。你应该Google "Cannot find module 'npm'" 简单来说,就是无法找到$NODE_PATH。你可以通过echo $NODE_PATH查看。你的应该是空。

from candy.

hudidit avatar hudidit commented on September 25, 2024

@harrylu 多谢!NODE_PATH这个问题用你的方法解决了。
你在控制台打log的那段代码写在哪里呢?

from candy.

guo-yu avatar guo-yu commented on September 25, 2024

Error: Cannot find module 'npm' 的问题也可以通过在本地依赖中安装 npm 解决 npm install npm

from candy.

hudidit avatar hudidit commented on September 25, 2024

@turingou 谢谢。npm的问题已经解决了,但是 theme not found 的问题还在,请问我应该怎样查找问题原因呢?比如harrylu的打log的方法,那段代码应该写在哪里?多谢指点!

from candy.

harrylu101 avatar harrylu101 commented on September 25, 2024
  1. 我打log的地方,你看看这个comment (https://github.com/turingou/candy/issues/34#issuecomment-38386778)。
    我忘记是哪个文件里了。你自己找一下看。
  2. 我最后解决"theme not found" 是用了这个办法: #34 (comment)

from candy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.