[Front-end] When executing cnpm i, an error message appears: Error: Cannot find module 'fs/promises'


1. Question:

Insert image description here

2. Analysis:

Since the introduction of promises in lower versions of Node.js is different from that in higher versions, the introduction of promises fails;
cnpm版本太高node does not support the 'fs/promises' introduction method;

3. Solution (choose one of the two):

Find the installation path of node=》where node

【1】Upgrade node version

# 第一步清理npm缓存:
npm cache clean -f
# 第二步运行npm安装工具
npm -g install n
# 第三步运行n stabl(安装最新稳定版本)
n stable

/*
附带常用命令
n //会列出所有安装的版本供你切换
n latest //安装最新版本
n stable //安装最新稳定版
n lts //安装最新长期支持版本
n rm [版本号] //删除某一版本
n -h //帮助命令
*/

【2】Reduce the version of cnpm

# 第一步删除已安装的cnpm版本
npm uninstall -g cnpm
# 第二步安装低版本cnpm
npm install [email protected] -g --registry=https://registry.npm.taobao.org
4. Effect:

Insert image description here

Guess you like

Origin blog.csdn.net/weixin_53791978/article/details/128839345