fs-extra: source and destination must not be the same. (cordova)

懵懂的女人 提交于 2019-12-08 10:42:30

问题


I get an error while building with cordova.

Error: Source and destination must not be the same.

Build-System:

Ionic:
  ionic (cli):        4.10.1
  ionic framework:    ionic-angular 3.9.2
  @ionic/app-scripts: 3.1.11

Cordova:
  cordova (cli):      8.1.2 (cordova-lib@8.1.1)
  platforms:          "cordova-android": "8.0.0"

System:
  Android SDK Tools:  26.1.1
  NodeJS:             10.15.3
  npm:                6.4.1
  OS:                 Windows 10

Command:

ionic cordova build android

or

cordova build --release

Error-Details:

Error: Source and destination must not be the same.
    at checkPaths (C:\Jenkins\workspace\%PROJECTNAME%\node_modules\fs-extra\lib\copy-sync\copy-sync.js:185:11)
    at Object.copySync (C:\Jenkins\workspace\%PROJECTNAME%\node_modules\fs-extra\lib\copy-sync\copy-sync.js:25:20)
    at updatePathWithStats (C:\Jenkins\workspace\%PROJECTNAME%\node_modules\cordova-common\src\FileUpdater.js:103:24)
    at C:\Jenkins\workspace\%PROJECTNAME%\node_modules\cordova-common\src\FileUpdater.js:298:19
    at Array.forEach (<anonymous>)
    at Object.mergeAndUpdateDir (C:\Jenkins\workspace\%PROJECTNAME%\node_modules\cordova-common\src\FileUpdater.js:296:33)
    at updateWww (C:\Jenkins\workspace\%PROJECTNAME%\platforms\android\cordova\lib\prepare.js:157:17)
    at Api.module.exports.prepare (C:\Jenkins\workspace\%PROJECTNAME%\platforms\android\cordova\lib\prepare.js:56:19)
    at Api.prepare (C:\Jenkins\workspace\%PROJECTNAME%\platforms\android\cordova\Api.js:177:45)
    at C:\Jenkins\workspace\%PROJECTNAME%\node_modules\cordova\node_modules\cordova-lib\src\cordova\prepare.js:105:36

Does anyone facing the same error or has an idea what's wrong?

Additional infos: I always check out the git repository to a empty folder. This means: It's a hard-clean every build. No node_modules and no platform, etc. (rm platform etc. is useless)


回答1:


At first, manually remove this:

node_modules folder

package-lock.json file

platform > android folder

then use this commend:

1 => npm rm -rf node_modules package-lock.json
2 => npm cache clear --force
3 => ionic cordova platform add android@8.0.0
4 => ionic cordova prepare android
5 => ionic cordova run android



回答2:


The problem is fs-extra checkPaths method of copy operation. There is a check of state.ino (inode) of node fs which is evaluated as number. Bigint is also supported but not enabled. This is the reason that the comparsion can fail. Because max-safe-integer in JavaScript is 53-bit. Maybe also a symlink issue.

See / Join: https://github.com/jprichardson/node-fs-extra/issues/657

Why Cordova-Android 8.0.0? Because https://github.com/apache/cordova-common/blob/master/RELEASENOTES.md . fs-extra is new in this version.




回答3:


I don't know if this is the correct answer, but it could be a wrong setting in the cordova build.json (if you have one).

Since you are using Jenkins, maybe you have some wrong settings there like missing dependencies or something like that.

You can also try to remove the platform and add it again to get the latest version and compatibility.

cordova platform remove android
cordova platform add android@8.0.0

You can check if you have an outdated fs-extra (although I don't think that is the problem) and update Ionic.

You can try to restore your node_modules.

I hope one of these steps help.



来源:https://stackoverflow.com/questions/55127362/fs-extra-source-and-destination-must-not-be-the-same-cordova

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!