我们有一些使用添加的本地插件 离子cordova插件添加./cordova-plugin-name
在 intel mac 上构建时它们工作正常,但在带有 Big Sur 的新 M1 mac 中构建项目时出现以下错误
Discovered saved plugin "cordova-plugin-ionic-keyboard". Adding it to the project
Installing "cordova-plugin-ionic-keyboard" for ios
Adding cordova-plugin-ionic-keyboard to package.json
Discovered saved plugin "cordova-plugin-iovation". Adding it to the project
Failed to restore plugin "cordova-plugin-iovation" from config.xml. You might need to try adding it again. Error: Failed to fetch plugin file:scripts/plugin/cordova-plugin-iovation 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!
Cannot read property 'match' of undefined
npm ERR!
npm ERR!
Discovered saved plugin "cordova-plugin-advanced-http". Adding it to the project
Failed to restore plugin "cordova-plugin-advanced-http" from config.xml. You might need to try adding it again. Error: Failed to fetch plugin file:scripts/plugin/cordova-plugin-advanced-http via re gistry.
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!
Cannot read property 'match' of undefined
A complete log of this run can be found in: /Users/xx/.npm/_logs/2021-01-21T12_29_50_477Z-debug.log
npm ERR!
npm ERR!
Discovered saved plugin "call-number". Adding it to the project
Installing "mx.ferreyra.callnumber" for ios
Adding mx.ferreyra.callnumber to package.json
Discovered saved plugin "cordova-plugin-app-version". Adding it
Installing "cordova-plugin-app-version" for ios
这是一个已知问题吗?我该如何解决?
答案 0 :(得分:1)
看起来 CLI 不知道这些是本地插件,因此它尝试从注册表下载它们。这很可能是 npm 问题。使用cordova 和npm 7 的东西不太好。我建议你运行node v15.6.0(最新的非lts)。
此版本通常与较新的 npm (v7) 捆绑在一起,但是要使其正常工作(直到cordova 整理它们的内容),您必须将 npm 降级到 6.14.11
我已经这样做了(是否使用 sudo 取决于您的环境设置):
sudo npm i -g npm
或者你可以指定一个版本:
sudo npm i -g npm@version
上述解决方案的来源: https://github.com/apache/cordova-cli/issues/541
除此之外,我只需要争取几个小时就可以在我的 M1 上构建东西......
一些可能会对您有很大帮助的提示:
更新:看起来cordova 现在已经通过整理它们的依赖项来解决这个问题。卸载并重新安装cordova 应该会获得它与最新的稳定npm 一起工作所需的所有包