在解决用户遇到的问题时,文章详细描述了由于执行npm install命令时出现错误而导致的报错情况。错误信息显示,在安装ejs模块的postinstall阶段,由于node命令权限不足导致失败,同时npm警告了fsevents模块的依赖问题,因为当前平台不支持。文章提供了完整的错误日志路径,并最终给出了解决方案:首先删除node_modules和package-lock.json文件,然后清理npm缓存并使用--force参数强制重新安装npm依赖,以成功完成安装过程。
QA!
由于布置不知道哪一步错了,所以他就报错了,经过我的不懈终于解决
错误如下
bash
npm install
> ejs@2.7.4 postinstall /root/blog/node_modules/ejs
> node ./postinstall.js
sh: 1: node: Permission denied
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@~2.1.2 (node_modules/chokidar/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm ERR! code ELIFECYCLE
npm ERR! syscall spawn
npm ERR! file sh
npm ERR! errno ENOENT
npm ERR! ejs@2.7.4 postinstall: `node ./postinstall.js`
npm ERR! spawn ENOENT
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-10-30T23_06_47_863Z-debug.log
解决办法
bash
rm -rf node_modules
rm -rf package-lock.json
npm cache clean --force
npm install --force