首页 > 解决方案 > npm 错误!在netbeans中使用cordova时编码ENOPACKAGEJSON

问题描述

我正在尝试让科尔多瓦与 netbeans 一起运行。我不断收到错误消息,

我创建了一个由netbeans提供的helloworld html5应用程序,我下载了android studios、node.js、git和cordova,并设置了路径。当我在命令行中检查 git 和 cordova 的版本时,一切都很好。请指教。 报错信息截图

check-android-template:
check-cordova-version:
check-cordova-project:
upgrade-to-cordova-project:
create-android:
update-plugins:
cordova.cmd plugins 
cordova.cmd -d plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs.git
No scripts found for hook "before_plugin_add".
Calling plugman.fetch on plugin "https://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs.git"
fetch: Installing https://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs.git to C:\Users\SONY\Documents\NetBeansProjects\HTML5Application
Running command: npm install https://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs.git --production --save
Failed to fetch plugin https://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs.git via registry.Command finished with error code 1: npm install,https://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs.git,--production,--save
Probably this is either a connection problem, or plugin spec is incorrect.
Check your connection and plugin name/version/URL.
Error: npm: Command failed with exit code 1 Error output:
npm ERR! code ENOPACKAGEJSON
npm ERR! package.json Non-registry package missing package.json: https://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs.git.
npm ERR! package.json npm can't find a package.json file in your current directory.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\SONY\AppData\Roaming\npm-cache\_logs\2019-08-10T17_29_09_382Z-debug.log

CordovaError: Failed to fetch plugin https://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs.git via registry.
Probably this is either a connection problem, or plugin spec is incorrect.
Check your connection and plugin name/version/URL.
Error: npm: Command failed with exit code 1 Error output:
npm ERR! code ENOPACKAGEJSON
npm ERR! package.json Non-registry package missing package.json: https://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs.git.
npm ERR! package.json npm can't find a package.json file in your current directory.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\SONY\AppData\Roaming\npm-cache\_logs\2019-08-10T17_29_09_382Z-debug.log
    at C:\Users\SONY\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\src\plugman\fetch.js:146:43
    at processTicksAndRejections (internal/process/task_queues.js:85:5)
C:\Users\SONY\Documents\NetBeansProjects\HTML5Application\nbproject\build.xml:235: exec returned: 1
BUILD FAILED (total time: 48 seconds)

标签: jsoncordovanetbeansinstallation

解决方案


看起来您正在尝试在npm install没有package.json的情况下运行。

如果没有任何方法来重现这些步骤,就不可能知道发生了什么。但是您可以通过运行然后运行或者如果它是一个 Android 应用程序来创建一个package.json 。npm initnpm i -S cordovanpm i -S cordova-android


推荐阅读