Jamling / hexo-theme-nova

Hexo theme, used by https://www.ieclipse.cn
MIT License
42 stars 21 forks source link

感觉依赖有问题(Cannot find module) #9

Open ctaoist opened 7 years ago

ctaoist commented 7 years ago

提示: Error: Cannot find module '../../../node_modules/hexo/node_modules/lodash' Error: Cannot find module '../../../node_modules/hexo/node_modules/cheerio' 导致失败 我的hexo是3.x

Jamling commented 7 years ago

请看一下你的博客根目录/node_modules/hexo/node_modules/目录下是否有

├─cheerio
├─lodash

这两个目录,如果没有,可以在博客根目录/node_modules/hexo下安装这两个插件

npm install cheerio --save
npm install lodash --save
ctaoist commented 7 years ago

装了之后在 博客根目录/node_modules/下有lodash,而博客根目录/node_modules/hexo/node_modules/下是没有的. cheerio是在两者下都有 直接修改相应js中lodash的位置可以?

Jamling commented 7 years ago

@275761919 已修改我之前的备注。 '../../../node_modules/hexo/node_modules/lodash' 指向的位置是博客根目录/node_modules/hexo/node_modules/lodash。你的cheerio在hexo的依赖中,那么不应该出现Error: Cannot find module '../../../node_modules/hexo/node_modules/cheerio' (对此,我很奇怪)。

暂且不管。万能的解决办法是:

  1. 在博客根目录下安装 lodash和cheerio。
  2. 修改theme/nova/scripts/helper.js和project.js,将require lodash和cheerio的地方改成
require ('lodash');
require ('cheerio');

即可