node.js - 如果没有这样的文件,npm 模块将不会执行,但它确实存在

标签 node.js npm windows-10 git-bash

运行 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 子系统:Windows 上的 Bash)安装了此软件包;这样 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

关于node.js - 如果没有这样的文件,npm 模块将不会执行,但它确实存在,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49515653/

相关文章:

javascript - 如何在 vue-cli 上更改 main.js 的路径?

javascript - 如何发布同时具有 commonjs 和 es6 版本的 NPM 模块?

javascript - 如何在不知道首先执行哪个 then() 的情况下返回已解决的 promise

node.js - 通过 sails.js 中的关联

javascript - 前导小数点可能与点混淆

node.js - 无法全局安装 express

c# - 如何在 switch 语句中使用字符串资源

c# - 在 ScrollViewer (UWP) 中移动图像

windows - Katalon Localhost Agent - 无需登录即可在 Windows 启动时启动

Node.js 在 Kubernetes 上横向扩展