npm 模块不会在没有这样的文件的情况下执行,但它确实存在

npm module will not execute with no such file, but it does exists

运行 Windows 10 和 git bash.

我正在尝试 运行 webdriver io npm 模块。它显然存在于我的系统中,但是当我尝试 运行 它会说没有这样的文件。我对 npm 本身没有任何问题。

有什么想法吗?

usery@AUS-LT-384 MINGW64 ~/github/e2e-temp (master)
$ lr ./node_modules/.bin/wdio
-rw-r--r-- 1 user 1049089 23 Mar 27 09:15 ./node_modules/.bin/wdio

user@AUS-LT-384 MINGW64 ~/github/e2e-temp (master)
$ ./node_modules/.bin/wdio wdio.conf.js
./node_modules/.bin/wdio: line 1: ../webdriverio/bin/wdio: No such file or directory

user@AUS-LT-384 MINGW64 ~/github/e2e-temp (master)
$ npm -v
5.6.0

您可能是通过另一个系统(linux 可能)或 WSL(Linux 的 Windows 子系统:Bash 在 windows 上安装了此软件包) ;这样 npm 可执行文件(/node_modules/.bin 目录内容)就不会是 运行.

首先通过 WSL 卸载它来重新安装软件包:

npm uninstall wdio

然后通过 git-bash 安装:

npm install wdio

应该可以解决这个问题。如果没有,请尝试通过 Windows 终端 (CMD 或 PowerShell)安装软件包。这样,在 ./node_modules/.bin/ 目录中,您应该在 wdio 文件旁边看到一个 wdio.cmd 文件,并且您的可执行文件已准备就绪:

user@AUS-LT-384 MINGW64 ~/github/e2e-temp (master)
$ ./node_modules/.bin/wdio -v
v4.12.0

如果您使用 package.json,您可以包含脚本并使其更容易 运行

"scripts": {
  "tests": "wdio wdio.conf.js"
}

和运行他们与

npm run tests

如果您正在使用 5.x.x 然后先安装 cli

npm i --save-dev @wdio/cli