Cordova npm ERR! package.json npm can‘t find a package.json file in your current directory.

本文讲述了在Cordova项目中遇到的插件安装错误,原因可能是内网路径问题或缺少package.json。通过排查和调整,作者分享了正确添加git+协议的插件URL,并提供了解决步骤,确保了插件的顺利安装。

Failed to fetch plugin https://git.xxx-plugin.git via registry.

Probably this is either a connection problem, or plugin spec is incorrect.

Check your connection and plugin name/version/URL.

CordovaError: 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.xxx-plugin.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! /Users/xxx/.npm/_logs/2020-10-15T03_24_04_879Z-debug.log

 

现象:在cordova项目重新添加自定义plugin的时候报错,我使用的命令是:cordova plugin add https://git.xxxx/xxx-cordova-plugin.git

原因分析:

1.可能是我这个插件部署在公司内网,所以需要在内网才能安装插件;

2.插件版本被固定了,#之后的内容,貌似固定了版本的签名

要删除

3.删除原有插件的文件夹

4.添加命令可能错了:

cordova plugin add https://git.xxxx/xxx-cordova-plugin.git  错误

cordova plugin add git+https://git.xxxx/xxx-cordova-plugin.git 正确

至此重新安装修改后的插件成功。

 

 
npm error code 2 npm error path F:\node.js\node_20.18.0\node_global\node_modules\cordova-hot-code-push-cli\node_modules\leveldown npm error command failed npm error command C:\WINDOWS\system32\cmd.exe /d /s /c prebuild --install npm error prebuild info begin Prebuild version 4.5.0 npm error prebuild ERR! configure error npm error prebuild ERR! stack Error: Command failed: F:\python\python.EXE -c import sys; print "%s.%s.%s" % sys.version_info[:3]; npm error prebuild ERR! stack File "<string>", line 1 npm error prebuild ERR! stack import sys; print "%s.%s.%s" % sys.version_info[:3]; npm error prebuild ERR! stack ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ npm error prebuild ERR! stack SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)? npm error prebuild ERR! stack npm error prebuild ERR! stack at genericNodeError (node:internal/errors:984:15) npm error prebuild ERR! stack at wrappedFn (node:internal/errors:538:14) npm error prebuild ERR! stack at ChildProcess.exithandler (node:child_process:422:12) npm error prebuild ERR! stack at ChildProcess.emit (node:events:519:28) npm error prebuild ERR! stack at maybeClose (node:internal/child_process:1105:16) npm error prebuild ERR! stack at ChildProcess._handle.onexit (node:internal/child_process:305:5) npm error prebuild ERR! not ok npm error prebuild ERR! build Error: Command failed: F:\python\python.EXE -c import sys; print "%s.%s.%s" % sys.version_info[:3]; npm error prebuild ERR! build File "<string>", line 1 npm error prebuild ERR! build import sys; print "%s.%s.%s" % sys.version_info[:3]; npm error prebuild ERR! build ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ npm error prebuild ERR! build SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)? npm error prebuild ERR! build npm error prebuild ERR! build at genericNodeError (node:internal/errors:984:15) npm error prebuild ERR! build at wrappedFn (node:internal/errors:538:14) npm error prebuild ERR! build at ChildProcess.exithandler (node:child_process:422:12) npm error prebuild ERR! build at ChildProcess.emit (node:events:519:28) npm error prebuild ERR! build at maybeClose (node:internal/child_process:1105:16) npm error prebuild ERR! build at ChildProcess._handle.onexit (node:internal/child_process:305:5) npm error A complete log of this run can be found in: F:\node.js\node_20.18.0\node_cache\_logs\2025-09-18T00_59_07_294Z-debug-0.log是什么问题,怎么解决
最新发布
09-19
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值