报错记录:升级package.json依赖包

最近老大布置了个任务,升级JS库,升级的过程中遇到了一些问题,记录下。

问题1:

在package.json中更新版本后,执行yarn install, 报错:

1
node-pre-gyp ERR! Tried to download(undefined): https://fsevents-binaries.s3-us-west-2.amazonaws.com/v1.1.2/fse-v1.1.2-node-v64-darwin-x64.tar.gz

本地Node 10.6.9, npm 6.4.1.

打开https://fsevents-binaries.s3-us-west-2.amazonaws.com,list里面确实没有这个版本的fsevents.

解决:

Google后,发现fsevents#196 中有提到类似的问题。

解决方法也很简单,下载符合版本要求的node,可以找到fsevents的下载包,这里我下载了[email protected],版本号:8.12.0.

终端执行:

1
2
3
4
5
node -v
brew unlink node
brew search node
brew install [email protected] ##这里选择[email protected],如果已经有[email protected],则无须安装
brew link [email protected]

再次执行yarn install, OK。

问题2:

执行bin/webpack-dev-server 报错:

1
Cannot find module 'webpack-cli/bin/config-yargs'

本地webpack 3.12.0, 想要升级webpack-dev-server至最新版3.1.9.

解决:

Google,在webpack-dev-server releasev3.0.0中,明确指出了 webpack-dev-server 3.x 支持 webpack 4.x,不再支持旧版本webpack.

1
Breaking change: webpack v4 is now supported. Older versions of webpack are not supported.

两种解决方法:升级webpack为v4+ 或者 降级 webpack-dev-server 为v2+.

参考:

Pre-built binaries not found for [email protected] and [email protected]

cannot find module ‘webpack/bin/config-yargs’