gpt4 book ai didi

cordova - npm 错误!添加cordova插件时的代码ENOENT(cordova删除它正在查找的文件)

转载 作者:行者123 更新时间:2023-12-02 17:47:14 27 4
gpt4 key购买 nike

我陷入了某种无限的挣扎循环之中!请帮忙xD

无论我运行什么phonegap或cordova cli命令,cordova似乎都会删除它之前查找的文件。

以下是一些会触发错误的已知命令:

$ cordova plugin add <plugin name>

$ phonegap plugin add <plugin name>

$ cordova platform update <platform name>

$ phonegap platform update <platform name>

$ cordova platform remove <platform name>

$ phonegap platform remove <platform name>

请参阅下面的终端输出,其中显示了运行这些命令时得到的输出。我真的不确定为什么 Cordova 在尝试重命名之前删除它试图重命名的文件。非常令人沮丧!

第 1 步(检查以确保我们有一个干净的 git head 并且我们的工作集没有更改)

apple@Child-2:~/projects/infiniteinternet/prodmode/prodmode-client-mobile-builds/phonegap * feature-barcode-scanner$ git status
# On branch feature-barcode-scanner
nothing to commit, working directory clean

第 2 步(尝试添加插件)

apple@Child-2:~/projects/infiniteinternet/prodmode/prodmode-client-mobile-builds/phonegap * feature-barcode-scanner$ cordova plugin add phonegap-plugin-barcodescanner --variable CAMERA_USAGE_DESCRIPTION="To scan barcodes"
Unmet project requirements for latest version of phonegap-plugin-barcodescanner:
cordova-android (6.2.3 in project, >=6.3.0 required)
Fetching highest version of phonegap-plugin-barcodescanner that this project supports: 6.0.8 (latest is 7.0.0)
Error: Failed to fetch plugin phonegap-plugin-barcodescanner@6.0.8 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 254 Error output:
npm WARN cordova-plugin-file-transfer@1.5.1 requires a peer of cordova-plugin-file@^3.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN cordova-plugin-media-capture@1.2.0 requires a peer of cordova-plugin-file@^3.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN com.prodmod.mobileclient@1.0.0 No repository field.
npm WARN com.prodmod.mobileclient@1.0.0 No license field.

npm ERR! path prodmode-client-mobile-builds/phonegap/node_modules/cordova-ios/node_modules/simple-plist/node_modules/base64-js
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall rename
npm ERR! enoent ENOENT: no such file or directory, rename 'prodmode-client-mobile-builds/phonegap/node_modules/cordova-ios/node_modules/simple-plist/node_modules/base64-js' -> 'prodmode-client-mobile-builds/phonegap/node_modules/cordova-ios/node_modules/simple-plist/node_modules/.base64-js.DELETE'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent

┌──────────────────────────────────────────────────────────┐
│ npm update check failed │
│ Try running with sudo or get access │
│ to the local update config store via │
│ sudo chown -R $USER:$(id -gn $USER) /Users/apple/.config │
└──────────────────────────────────────────────────────────┘

npm ERR! A complete log of this run can be found in:
npm ERR! .npm/_logs/2017-11-10T00_23_21_467Z-debug.log

第3步(检查第2步中的命令引起的git更改)

好吧,所以失败了。让我们看看假设丢失的文件发生了什么。嗯,显然 cordova 在查找文件之前就删除了该文件?

apple@Child-2:~/projects/infiniteinternet/prodmode/prodmode-client-mobile-builds/phonegap * feature-barcode-scanner$ git status
# On branch feature-barcode-scanner
# Changes not staged for commit:
# (use "git add/rm <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# deleted: node_modules/cordova-ios/node_modules/simple-plist/node_modules/base64-js/.npmignore
# deleted: node_modules/cordova-ios/node_modules/simple-plist/node_modules/base64-js/.travis.yml
# deleted: node_modules/cordova-ios/node_modules/simple-plist/node_modules/base64-js/LICENSE.MIT
# deleted: node_modules/cordova-ios/node_modules/simple-plist/node_modules/base64-js/README.md
# deleted: node_modules/cordova-ios/node_modules/simple-plist/node_modules/base64-js/base64js.min.js
# deleted: node_modules/cordova-ios/node_modules/simple-plist/node_modules/base64-js/bower.json
# deleted: node_modules/cordova-ios/node_modules/simple-plist/node_modules/base64-js/lib/b64.js
# deleted: node_modules/cordova-ios/node_modules/simple-plist/node_modules/base64-js/package.json
# deleted: node_modules/cordova-ios/node_modules/simple-plist/node_modules/base64-js/test/big-data.js
# deleted: node_modules/cordova-ios/node_modules/simple-plist/node_modules/base64-js/test/convert.js
# deleted: node_modules/cordova-ios/node_modules/simple-plist/node_modules/base64-js/test/url-safe.js
# deleted: node_modules/cordova-ios/node_modules/simple-plist/node_modules/plist/.jshintrc
# deleted: node_modules/cordova-ios/node_modules/simple-plist/node_modules/plist/.travis.yml
# deleted: node_modules/cordova-ios/node_modules/simple-plist/node_modules/plist/History.md
# deleted: node_modules/cordova-ios/node_modules/simple-plist/node_modules/plist/LICENSE
# deleted: node_modules/cordova-ios/node_modules/simple-plist/node_modules/plist/Makefile
# deleted: node_modules/cordova-ios/node_modules/simple-plist/node_modules/plist/README.md
# deleted: node_modules/cordova-ios/node_modules/simple-plist/node_modules/plist/dist/plist-build.js
# deleted: node_modules/cordova-ios/node_modules/simple-plist/node_modules/plist/dist/plist-parse.js
# deleted: node_modules/cordova-ios/node_modules/simple-plist/node_modules/plist/dist/plist.js
# deleted: node_modules/cordova-ios/node_modules/simple-plist/node_modules/plist/examples/browser/index.html
# deleted: node_modules/cordova-ios/node_modules/simple-plist/node_modules/plist/index.js
# deleted: node_modules/cordova-ios/node_modules/simple-plist/node_modules/plist/lib/build.js
# deleted: node_modules/cordova-ios/node_modules/simple-plist/node_modules/plist/lib/parse.js
# deleted: node_modules/cordova-ios/node_modules/simple-plist/node_modules/plist/package.json
# deleted: node_modules/cordova-ios/node_modules/simple-plist/node_modules/xmlbuilder/.npmignore
# deleted: node_modules/cordova-ios/node_modules/simple-plist/node_modules/xmlbuilder/CHANGELOG.md
# deleted: node_modules/cordova-ios/node_modules/simple-plist/node_modules/xmlbuilder/LICENSE
# deleted: node_modules/cordova-ios/node_modules/simple-plist/node_modules/xmlbuilder/README.md
# deleted: node_modules/cordova-ios/node_modules/simple-plist/node_modules/xmlbuilder/lib/Utility.js
# deleted: node_modules/cordova-ios/node_modules/simple-plist/node_modules/xmlbuilder/lib/XMLAttribute.js
# deleted: node_modules/cordova-ios/node_modules/simple-plist/node_modules/xmlbuilder/lib/XMLCData.js
# deleted: node_modules/cordova-ios/node_modules/simple-plist/node_modules/xmlbuilder/lib/XMLComment.js
# deleted: node_modules/cordova-ios/node_modules/simple-plist/node_modules/xmlbuilder/lib/XMLDTDAttList.js
# deleted: node_modules/cordova-ios/node_modules/simple-plist/node_modules/xmlbuilder/lib/XMLDTDElement.js
# deleted: node_modules/cordova-ios/node_modules/simple-plist/node_modules/xmlbuilder/lib/XMLDTDEntity.js
# deleted: node_modules/cordova-ios/node_modules/simple-plist/node_modules/xmlbuilder/lib/XMLDTDNotation.js
# deleted: node_modules/cordova-ios/node_modules/simple-plist/node_modules/xmlbuilder/lib/XMLDeclaration.js
# deleted: node_modules/cordova-ios/node_modules/simple-plist/node_modules/xmlbuilder/lib/XMLDocType.js
# deleted: node_modules/cordova-ios/node_modules/simple-plist/node_modules/xmlbuilder/lib/XMLDocument.js
# deleted: node_modules/cordova-ios/node_modules/simple-plist/node_modules/xmlbuilder/lib/XMLDocumentCB.js
# deleted: node_modules/cordova-ios/node_modules/simple-plist/node_modules/xmlbuilder/lib/XMLElement.js
# deleted: node_modules/cordova-ios/node_modules/simple-plist/node_modules/xmlbuilder/lib/XMLNode.js
# deleted: node_modules/cordova-ios/node_modules/simple-plist/node_modules/xmlbuilder/lib/XMLProcessingInstruction.js
# deleted: node_modules/cordova-ios/node_modules/simple-plist/node_modules/xmlbuilder/lib/XMLRaw.js
# deleted: node_modules/cordova-ios/node_modules/simple-plist/node_modules/xmlbuilder/lib/XMLStreamWriter.js
# deleted: node_modules/cordova-ios/node_modules/simple-plist/node_modules/xmlbuilder/lib/XMLStringWriter.js
# deleted: node_modules/cordova-ios/node_modules/simple-plist/node_modules/xmlbuilder/lib/XMLStringifier.js
# deleted: node_modules/cordova-ios/node_modules/simple-plist/node_modules/xmlbuilder/lib/XMLText.js
# deleted: node_modules/cordova-ios/node_modules/simple-plist/node_modules/xmlbuilder/lib/XMLWriterBase.js
# deleted: node_modules/cordova-ios/node_modules/simple-plist/node_modules/xmlbuilder/lib/index.js
# deleted: node_modules/cordova-ios/node_modules/simple-plist/node_modules/xmlbuilder/package.json
#
no changes added to commit (use "git add" and/or "git commit -a")

如果有人对如何解决此问题有任何建议,我将非常感激。我不确定是什么导致了它或它何时生效,但已经有几个星期了我无法向我的项目添加插件。

提前致谢!

编辑:环境设置:

apple@Child-2:/ $ cordova --version
7.0.1


┌──────────────────────────────────────────┐
│ Update available: 7.1.0 (current: 7.0.1) │
│ Run npm install -g cordova to update. │
└──────────────────────────────────────────┘

apple@Child-2:/ $ phonegap --version
7.1.1
apple@Child-2:/ $ node --version
v6.11.1
apple@Child-2:/ $ npm --version
5.4.2

最佳答案

我真的不知道您的项目中存在问题,但当我升级 cordova 版本并将项目从 Eclipse 迁移到 Android Studio 时,我也遇到了类似的行为。

添加一些插件会导致多次删除,并且我的所有项目不起作用

我尝试了很多方法来修复它,但都失败了,每次都出现其他异常。

<小时/>

所以我通过从头开始创建新项目来解决这个问题。一一添加所有插件,然后复制旧项目中的所有 www 文件夹。

我花了大约 30 分钟,但这是值得的。

<小时/>

提示:我会将 node_modules 文件夹放入 .gitignore 文件中。您不需要将所有依赖项推送到 git。用户可以克隆项目并只需从根项目运行 $ npm install 即可。

关于cordova - npm 错误!添加cordova插件时的代码ENOENT(cordova删除它正在查找的文件),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47214086/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com