Cannot find module './src/superspawn'
Bug Report
Cannot add platform [email protected]
Problem
Cannot add platform [email protected] to a newly created cordova project
What is expected to happen?
platform should be added without error messages
What does actually happen?
error message occurs: Cannot find module './src/superspawn'
Using cordova-fetch for [email protected]
Adding ios project...
Creating Cordova project for the iOS platform:
Path: platforms/ios
Package: io.cordova.hellocordova
Name: HelloCordova
iOS project created with [email protected]
Discovered plugin "cordova-plugin-whitelist" in config.xml. Adding it to the project
Installing "cordova-plugin-whitelist" for ios
Failed to install 'cordova-plugin-whitelist': Error: Cannot find module './src/superspawn'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:581:15)
at Function.Module._load (internal/modules/cjs/loader.js:507:25)
at Module.require (internal/modules/cjs/loader.js:637:17)
at Object.get (/Volumes/dev/schauerte/cleverdox/test/test/node_modules/cordova-common/src/util/addProperty.js:27:44)
at Object.<anonymous> (/Volumes/dev/schauerte/cleverdox/test/test/platforms/ios/cordova/lib/Podfile.js:26:43)
at Module._compile (internal/modules/cjs/loader.js:689:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
at Module.load (internal/modules/cjs/loader.js:599:32)
at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
at Function.Module._load (internal/modules/cjs/loader.js:530:3)
Failed to restore plugin "cordova-plugin-whitelist" from config.xml. You might need to try adding it again. Error: Error: Cannot find module './src/superspawn'
--save flag or autosave detected
Saving ios@~5.0.0 into config.xml file ...
Information
cordova platform add [email protected] works fine
Command or Code
cordova create test
cd test
cordova platform add [email protected]
Environment, Platform, Device
Using cordova via commandline on MacOS Mojave
Version information
MacOS: Mojave 1014.3 Cordova: 8.1.2 ([email protected]) node: v10.15.1 npm: 6.4.1
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'm having the same issue migrating from 4.5.4 to 5.0.0 on our build server (not sure yet which hardware that is, though it's a mac).
On my macbook pro I don't have this issue, which is odd. Working specs: OS: High Sierra 10.13.6 Cordova: 8.1.2 Node: v8.12.0 (v10.15.1 also works) npm: 6.4.1
update: The specs of the mac that is failing: OS: High Sierra 10.13.4 Cordova: 8.0.0 Node: 10.8.0 Npm: 6.2.0
update2: So I managed to get the error locally as well by removing the node_modules folder and installing the npm packages again
@temo44 cordova-ios 5.0.0 as well?
Yes. If it helps I can list the packages we use. Maybe there's a version mismatch with cordova-ios?
as I mentioned in my bug description the error even occurs without any additional plugins or packages installed to the cordova app.
@regnete for me, cordova prepare fails with the superspawn error, while the cordova platform add [email protected]works.. very strange..
I've got the same issue going on. Is there a place I can run a npm install --no-save superspawn to workaround this for now?
We cannot proceed with cordova-ios upgrades unless this issue is addressed.
This happens to me if I use platform add --nosave. When using platform add it works as expected.
You can also try npm install cordova-ios before platform add.
I had added ios platform using ionic cordova platform add ios
Then later executed the code using ionic cordova run ios
i got the error as Error: Cannot find module './src/superspawn'
Then i used command npm install
this fixed my issue.
Here is a reference behind what npm's --no-save flag is doing and why it causes this issue.
https://github.com/apache/cordova/issues/91#issuecomment-478555601
I think we've confirmed that this is caused by using --no-save, but the root issue is in npm rather than Cordova.
If anyone encounters this in the future, I was getting the same error, and I was not using the --no-save flag. Our config.xml was where the plugins were being installed from, but I remembered them being installed from package.json from a previous project. I changed it so the platforms and plugins were installed from package.json (and not config.xml), and the error went away. With this approach, you no longer have to explicitly add the platforms or plugins (e.g. cordova platform add ios) - they are automatically installed when you execute "cordova prepare ios".