下载依赖时提示某个依赖的node版本不兼容

问题 1、 node 版本不兼容

@achrinza/node-ipc@9.2.2: The engine “node” is incompatible with this module. Expected version “8 || 10 || 12 || 14 || 16 || 17”. Got “20.15.0” 报错为例

  1. 去 npmjs.com 查看该依赖对应的 node 版本要求
  2. 找到后在 package.json 中添加如下代码
1
2
3
"resolutions": {
"@achrinza/node-ipc": "9.2.9"
},

问题 2、webpack 打包时验证 node_modules 代码

1
2
3
4
5
6
## vue.config.js
transpileDependencies: [/node_modules/],

## tsconfig.json
"exclude": ["node_modules"]

问题 3、fs 模块报错

1
2
3
4
5
6
7
8
9
10
## vue.config.js

parallel: false,
configureWebpack: {
resolve: {
fallback: {
fs: false,
},
}
}