报错信息如下

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
> ejs@2.7.4 postinstall /root/sw/blog/node_modules/hexo-renderer-ejs/node_modules/ejs
> node ./postinstall.js

internal/modules/cjs/loader.js:1023
throw err;
^

Error: Cannot find module '/root/sw/blog/node_modules/hexo-renderer-ejs/node_modules/ejs/postinstall.js'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:1020:15)
at Function.Module._load (internal/modules/cjs/loader.js:890:27)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
at internal/main/run_main_module.js:17:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! ejs@2.7.4 postinstall: `node ./postinstall.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the ejs@2.7.4 postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2020-08-18T08_24_47_894Z-debug.log

我出现这个问题的原因是因为nodejs和npm版本不匹配?
解决方案就是删除自己安装的nodejs和npm,重新安装。

我用一个第三方node版本管理软件解决了

1
https://github.com/nvm-sh/nvm