SystemError [ERR_FS_CP_EINVAL]: Invalid src or dest: cp returned EINVAL during command cordova platform add android
Bug Report
Problem
In certain scenario (when there are nodue modules in www folder having sym link) cordova platform add android command fails
What is expected to happen?
Cordova platfprm add android should work as expected.
What does actually happen?
it gives below error
Invalid src or dest: cp returned EINVAL (cannot copy /Users/vbansal/Documents/Cordova_Workspace/test/www/node_modules/glob/dist/esm/bin.mjs to a subdirectory of self /Users/vbansal/Documents/Cordova_Workspace/test/www/node_modules/glob/dist/esm/bin.mjs) /Users/vbansal/Documents/Cordova_Workspace/test/platforms/android/app/src/main/assets/www/node_modules/.bin/glob
Information
It seems it gets confused due to to sym link if there in node_modules If i delete www/node_modules/.bin then issues goes away.
Command or Code
Following are the steps to reproduce it 100%
cordova create test com.test.blank Testapp cd test/www && npm init --yes npm i jasmine cd .. cordova platform add android
Environment, Platform, Device
Mac OS Android
Version information
Cordova- 12.0.0 ([email protected])
Node JS: 18.x, 20.x ,22.x all facing same issue
Checklist
- [x ] I searched for existing GitHub issues
- [x ] I updated all Cordova tooling to most recent version
- [ x] I included all the necessary information above
I also guess that also this issue start appearing after fs-extra 11.3.0 release on 15 Jan. Could this change (https://github.com/jprichardson/node-fs-extra/pull/1045/files)be the root cause ?
@cordova team please see if you like to fix the issue
@vbansal-bb Does this happen with cordova-android 14.0.0? fs-extra is no longer used in newer versions of the Android platform.
@dpogue yes. Issue occurs with cordov android 14.0.0 as well