使用vue开发了一个前端项目,本地一切都是没问题的。但是从git仓库拉下项目代码到服务器,运行npm install
安装项目所依赖的模块时却报错了,错误信息如下:
+ npm install --registry=https://registry.npm.taobao.org
> chromedriver@2.46.0 install /data/jenkinsslave/workspace/daoke_mq.monitor.web/node_modules/chromedriver
> node install.js
/data/jenkinsslave/workspace/daoke_mq.monitor.web/node_modules/te-one-utils/dist/promisify.js:7
read: util.promisify(fs.readFile),
^
TypeError: util.promisify is not a function
at Object.<anonymous> (/data/jenkinsslave/workspace/daoke_mq.monitor.web/node_modules/te-one-utils/dist/promisify.js:7:16)
at Module._compile (module.js:571:32)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load (module.js:439:3)
at Module.require (module.js:498:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/data/jenkinsslave/workspace/daoke_mq.monitor.web/node_modules/te-one-utils/dist/index.js:34:21)
at Module._compile (module.js:571:32)
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.2.3 (node_modules/sane/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.9: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.2.7 (node_modules/chokidar/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.9: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm ERR! Linux 4.11.1-1.el7.elrepo.x86_64
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "--registry=https://registry.npm.taobao.org"
npm ERR! node v7.10.0
npm ERR! npm v4.2.0
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! chromedriver@2.46.0 install: `node install.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the chromedriver@2.46.0 install script 'node install.js'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the chromedriver package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node install.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs chromedriver
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls chromedriver
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /home/jenkins/.npm/_logs/2019-07-23T03_13_32_194Z-debug.log
Build step 'Execute shell' marked build as failure
Finished: FAILURE
我明明没导入chromedriver这个模块,想着直接删除掉好了,但是 ,我手动删除之后重新install 又出来这个了, 估计就是新版node在构建项目的时候自动帮我加上的。
再看错误提示信息:错误提示版本有问题,果然本地和服务器的node版本是不一致的,本地:v10.12.0,服务器:v7.9,显然服务器的node版本太低,服务器的node版本不能直接升级,这样会影响到服务器上的其他项目,只能考虑切换版本,但是没切成功,最后解决方案如下:
解决方案:
npm install改为:npm install --ignore-scripts
--ignore-scripts 表示npm将不会运行在package.json中指定的scripts脚本