我正在使用量角器5.2.2。我有一个要求-将数据写入excel文件(以后我需要将动态变量传递到相同的excel文件。也就是说,每次运行时,应将不同的数据集输入到excel,所以我已经使用过编辑-xlsx)。我为此使用了以下代码。
var EditXlsx = require('edit-xlsx');
var xlsx = new EditXlsx('../files/exl.xlsx');
var sheet = xlsx.sheet(0);
var data = {
title: 'AKIRA'}
sheet.update('A1', 'Title');
但是当我运行量角器脚本时,它说“错误:找不到模块'edit-xlsx'”。当我通过命令'npm install edit-xlsx'安装了edit-xlsx时,会给出错误及其给出的信息下面(我也已经成功安装了python 2.7)。
F:\frx-automation>npm install edit-xlsx
> libxmljs@0.9.0 install F:\frx-automation\node_modules\libxmljs
> node-gyp rebuild
F:\frx-automation\node_modules\libxmljs>if not defined npm_config_node_gyp (node
"C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-
bin\\..\..\node_modules\
node-gyp\bin\node-gyp.js" rebuild ) else (node "" rebuild )
gyp ERR! configure error
gyp ERR! stack Error: Can't find Python executable "C:\Program Files
(x86)\Python37-32\python.EXE", you can set the PYTHON env variable.
gyp ERR! stack at PythonFinder.failNoPython (C:\Program
Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\configure.js:483:19)
gyp ERR! stack at PythonFinder.<anonymous> (C:\Program
Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\configure.js:508:16)
gyp ERR! stack at C:\Program
Files\nodejs\node_modules\npm\node_modules\graceful-fs\polyfills.js:284:29
gyp ERR! stack at FSReqWrap.oncomplete (fs.js:152:21)
gyp ERR! System Windows_NT 6.3.9600
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Program
Files\\nodej
s\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd F:\frx-automation\node_modules\libxmljs
gyp ERR! node -v v8.9.3
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok
npm WARN protractor-multiple-cucumber-html-reporter-plugin@1.7.0 requires a
peer of protractor@>= 4.0.0 but none is installed. You must install peer
dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.4
(node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for
fsevents@
1.2.4: wanted {"os":"darwin","arch":"any"}
(current{"os":"win32","arch":"x64"})
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! libxmljs@0.9.0 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the libxmljs@0.9.0 install script.
npm ERR! This is probably not a problem with npm. There is likely additional
logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\CS1027C\AppData\Roaming\npm-cache\_logs\2018-
020T03_43_13_721Z-debug.log
我做错了吗?谢谢
答案 0 :(得分:0)
edit-xlsx需要2.5到3.0之间的python版本
如果未安装,请使用以下命令将npm设置为2.7版,然后从here安装正确的版本
npm install --python=python2.7
然后使用
安装edit-xlsxnpm install edit-xlsx