Phonegap error: Cannot find module

Phonegap error: Cannot find module

我正在尝试创建 HelloWorld 项目,但遇到错误

phonegap create C:\Desenv\PhoneGap\learn com.cassia.hello HelloWorld

错误:

C:\Users\cassiasantos>phonegap create teste com.cassia.hello HelloWord
module.js:338
    throw err;
          ^
Error: Cannot find module '..\..\node_modules\cordova\node_modules\cordova-lib'
    at Function.Module._resolveFilename (module.js:336:15)
    at Function.Module._load (module.js:278:25)
    at Module.require (module.js:365:17)
    at require (module.js:384:17)
    at Object.<anonymous> (C:\Users\cassiasantos\AppData\Roaming\npm\node_module
s\phonegap\lib\cordova\index.js:16:26)
    at Module._compile (module.js:460:26)
    at Object.Module._extensions..js (module.js:478:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Module.require (module.js:365:17)

这是 phonegap 错误。 这是临时解决方案

Install cordova-lib under
../node_modules/phonegap/node_modules/cordova

转到 ../node_modules/phonegap/node_modules/cordova

执行npm install cordova-lib

看来您必须安装所有模块 - 至少这个修复对我有用。

使用

sudo npm update -g

ionic forum 中找到了解决方案。

我遇到了和你一样的问题。我刚刚卸载并重新安装了 NodeJS,这对我有用。

要在 Windows 上卸载 NodeJS,请转至控制面板 -> 程序和功能。在已安装软件列表中,您会找到 NodeJS。右键单击 NodeJS 并卸载它。

要重新安装 NodeJS,请访问他们的网站。 click here 访问他们的网站并下载最新的 LTS 版本的 NodeJS。

执行此操作后,检查您是否再次遇到相同的错误。如果你这样做,那么 运行 命令:

npm 安装-g phonegap

那绝对可以解决您的问题!干杯!