-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
打开后界面显示错误:ENOENT:没有这样的文件或目录,打开“themes/shoka/source/js/_app/utils.js” #39
Comments
不像是缺少什么 hexon 设置,可能是因为存在
|
我的hexo显示正常,hexon是刚安装的,现在用临时办法解决了这个问题,方法是把“themes/shoka/source/js/_app/utils.js”这个文件及路径在hexon的server目录下复制了一份,不知道是不是我对整体架构的理解有问题,目前blog路径d:\doc\blog和hexon路径d:\dev\hexon是分开的 |
似乎在读取这个文件的时候 hexon 使用了错误的 cwd。默认主题或者其他主题也会出现此问题么? |
默认主题没有问题 |
[hexo-instance-service][2023-09-26 11:34:51.479] Error: ENOENT: no such file or directory, open 'themes/shoka/source/js/_app/utils.js'
at Object.openSync (node:fs:590:3)
at Object.readFileSync (node:fs:458:35)
at Object.readFileSync (~/works/dev/test-blog/node_modules/hexo-fs/lib/fs.js:229:22)
at ~/works/dev/test-blog/themes/shoka/scripts/generaters/script.js:60:16
at Array.forEach (<anonymous>)
at Hexo.<anonymous> (~/works/dev/test-blog/themes/shoka/scripts/generaters/script.js:59:67)
... {
errno: -2,
syscall: 'open',
code: 'ENOENT',
path: 'themes/shoka/source/js/_app/utils.js'
} 定位了下:
diff --git a/scripts/generaters/script.js b/scripts/generaters/script.js
index 370ff7b..f5212c9 100644
--- a/scripts/generaters/script.js
+++ b/scripts/generaters/script.js
@@ -1,9 +1,11 @@
'use strict';
const fs = require('hexo-fs');
const url = require('url');
+const {resolve} = require('path')
hexo.extend.generator.register('script', function(locals){
+ const cwd = this.base_dir
const config = hexo.config;
const theme = hexo.theme.config;
@@ -57,11 +59,11 @@ hexo.extend.generator.register('script', function(locals){
var text = '';
['utils', 'dom', 'player', 'global', 'sidebar', 'page', 'pjax'].forEach(function(item) {
- text += fs.readFileSync('themes/shoka/source/js/_app/'+item+'.js').toString();
+ text += fs.readFileSync(resolve(cwd, 'themes/shoka/source/js/_app/'+item+'.js')).toString();
});
if(theme.fireworks && theme.fireworks.enable) {
- text += fs.readFileSync('themes/shoka/source/js/_app/fireworks.js').toString();
+ text += fs.readFileSync(resolve(cwd, 'themes/shoka/source/js/_app/fireworks.js')).toString();
siteConfig.fireworks = theme.fireworks.color || ["rgba(255,182,185,.9)", "rgba(250,227,217,.9)", "rgba(187,222,214,.9)", "rgba(138,198,209,.9)"]
} 如果还有问题,欢迎回复~ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
日志中显示:InternalServerError: Error: ENOENT: no such file or directory, open 'themes/shoka/source/js/_app/utils.js',是不是缺少什么设置?
The text was updated successfully, but these errors were encountered: