hexo-theme-nova icon indicating copy to clipboard operation
hexo-theme-nova copied to clipboard

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

Open ctaoist opened this issue 9 years ago • 3 comments

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

ctaoist avatar Aug 30 '16 05:08 ctaoist

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

├─cheerio
├─lodash

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

npm install cheerio --save
npm install lodash --save

Jamling avatar Aug 30 '16 10:08 Jamling

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

ctaoist avatar Aug 31 '16 03:08 ctaoist

@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');

即可

Jamling avatar Aug 31 '16 07:08 Jamling