项目的前端部分用到了人人开源的renren-fast-vue,下载node 之后又安装了npm(并且使用淘宝镜像npm config set registry http://registry.npm.taobao.org/),在vscode输入npm install想导入依赖时,报以下错误:

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! chromedriver@2.27.2 install: `node install.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the chromedriver@2.27.2 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm verb exit [ 1, true ]
npm timing npm Completed in 63695ms

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\001\AppData\Roaming\npm-cache\_logs\2021-03-09T05_36_52_742Z-debug.log

从报错信息可以看出,下载chromedriver失败了,这时更换数据源就可以了,将npm install更换为npm install chromedriver --chromedriver_cdnurl=http://cdn.npm.taobao.org/dist/chromedriver就行了

PS C:\Users\001\Desktop\renren-fast-vue> npm install chromedriver --chromedriver_cdnurl=http://cdn.npm.taobao.org/dist/chromedriver

> node install.js

Downloading http://cdn.npm.taobao.org/dist/chromedriver/2.27/chromedriver_win32.zip
Saving to C:\Users\001\AppData\Local\Temp\chromedriver\chromedriver_win32.zip
Receiving...
Received 781K...
Received 1570K...
Received 2352K...
Received 3158K...
Received 3579K total.
Extracting zip contents
Copying to target path C:\Users\001\Desktop\renren-fast-vue\node_modules\chromedriver\lib\chromedriver
Done. ChromeDriver binary available at C:\Users\001\Desktop\renren-fast-vue\node_modules\chromedriver\lib\chromedriver\chromedriver.exe
npm WARN ajv-keywords@1.5.1 requires a peer of ajv@>=4.10.0 but none is installed. You must install peer dependencies yourself.
npm WARN sass-loader@6.0.6 requires a peer of node-sass@^4.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.9 (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.9: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

+ chromedriver@2.27.2
added 3 packages from 2 contributors and removed 219 packages in 12.804s

再运行npm install:

PS C:\Users\001\Desktop\renren-fast-vue> npm install
npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated har-validator@5.1.5: this

> node-sass@4.13.1 install C:\Users\001\Desktop\renren-fast-vue\node_modules\node-sass
> node scripts/install.js

Downloading binary from https://github.com/sass/node-sass/releases/download/v4.13.1/win32-x64-64_binding.node
Download complete  ] - :
Binary saved to C:\Users\001\Desktop\renren-fast-vue\node_modules\node-sass\vendor\win32-x64-64\binding.node
Caching binary to C:\Users\001\AppData\Roaming\npm-cache\node-sass\4.13.1\win32-x64-64_binding.node

> node-sass@4.13.1 postinstall C:\Users\001\Desktop\renren-fast-vue\node_modules\node-sass
> node scripts/build.js

Binary found at C:\Users\001\Desktop\renren-fast-vue\node_modules\node-sass\vendor\win32-x64-64\binding.node
Testing binary
Binary is fine
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.9 (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.9: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

added 219 packages from 222 contributors in 133.78s

成功了。
输入npm run dev运行页面试试看:
在这里插入图片描述
哦了就。

Logo

前往低代码交流专区

更多推荐