Ionic Error: Cannot find module 'dezalgo' - ios

i am trying to add the ios platform to my project so i can build it in XCode. I ran the following command: ionic cordova platform add ios
this is the error i got:
ionic cordova platform add ios
> cordova platform add ios --save
module.js:544
throw err;
^
Error: Cannot find module 'dezalgo'
at Function.Module._resolveFilename (module.js:542:15)
at Function.Module._load (module.js:472:25)
at Module.require (module.js:585:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/Users/chando/Documents/GIT/testproject/node_modules/cordova-lib/node_modules/npm/lib/utils/correct-mkdir.js:2:15)
at Module._compile (module.js:641:30)
at Object.Module._extensions..js (module.js:652:10)
at Module.load (module.js:560:32)
at tryModuleLoad (module.js:503:12)
at Function.Module._load (module.js:495:3)
[ERROR] Exception:
i have tried multiple variations of deleting node_modules, installing the latest version of ionic, npm etc to no avail.
Has anyone else encountered this?
this is my ionic info:
cli packages: (/usr/local/lib/node_modules)
#ionic/cli-utils : 1.19.0
ionic (Ionic CLI) : 3.19.0
global packages:
cordova (Cordova CLI) : not installed
local packages:
#ionic/app-scripts : 2.1.4
Cordova Platforms : none
Ionic Framework : ionic-angular 3.9.2
System:
Node : v9.2.1
npm : 5.6.0
OS : macOS Sierra
Xcode : Xcode 9.2 Build version 9C40b
Environment Variables:
ANDROID_HOME : not set
Misc:
backend : pro

I had this issue come up after updating to the latest Ionic/Angular for my project this morning. This a work-around, but it worked for me:
Add "dezalgo": "~1.0" to your devDependencies section of package.json
Run npm prune
Run npm install
Build your project
I can't tell you why it works other than to guess that somewhere in all of the NPM modules somebody forgot to include this dependency. I should also note that I updated my global modules as well, but I doubt that that would have had any influence on this.

I'm using Node.js 9.7.0 and npm 5.6.0.
Doing a clean install with rm -rf node_modules && npm install also solves this error.
At the time of writing, the issue is still not fixed. Numerous people are complaining about this dezalgo error on several GitHub issue boards:
nodejs/node #13492
npm/npm #8635
npm/dezalgo #7
tjunnone/npm-check-updates #420
EDIT: this issue seems to appear when one of the dependencies relies on an older npm version (such as david or npm-check-updates packages).

Related

Cordova 8 + iOS 4.5.4 = cannot find module "../cordova/platform_metadata"

Since the latest update to v8 of Cordova, I cannot build anything on Mac.
I always get
(node 626) UnhandledPromiseRejectionWarning: Error: Cannot find module '../cordova/platform_metadata'
I tried what was suggested in this post but I get the same error.
I then did a verbose and it seems like the plugin required to build for ios is not working well
Executing script found in plugin cordova-plugin-swift-support for hook "after_prepare": plugins/cordova-plugin-swift-support/src/add-swift-support.js
Resolving module name for cordova-lib/src/cordova/platform_metadata => ../cordova/platform_metadata
(node:599) UnhandledPromiseRejectionWarning: Unhandled promise rejection
(rejection id: 1): Error: Cannot find module '../cordova/platform_metadata'
(node:599) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.
This was a bug in cordova-plugin-add-swift-support, just update it to latest version (1.7.1)
cordova plugin rm cordova-plugin-add-swift-support
cordova plugin add cordova-plugin-add-swift-support
you need to downgrade cordova 7.1.0 until this issue is fixed. Do this:
npm uninstall -g cordova
npm install -g cordova#7.1.0
cordova platform remove ios
cordova platform add ios
If your running an ionic project that requires the swift plugin you'll need to add the --force flag:
ionic cordova plugin rm cordova-plugin-add-swift-support --force
Then run:
ionic cordova plugin add cordova-plugin-add-swift-support
That just happened to me (using Ionic). In Ionic, the issue comes from a plugin or node_module that is still using cordova/platform_metadata, which is deprecated.
If you are using Linux, in your project directory, try this in the command shell:
grep -iRn 'platform_metadata'
In my case, it was the plugin cordova-plugin-add-swift-support that was still using that, and I wasn't even using that plugin my project, so I deleted it manually. Problem solved. The issue seems to arise when a plugin is calling a module that no longer exists, so you have to either remove that plugin or update it.
With Ionic 3 and Cordova 8.0.0 project.
Here are steps
ionic cordova platform remove ios
ionic cordova plugin rm cordova-plugin-add-swift-support
ionic cordova plugin add cordova-plugin-add-swift-support
ionic cordova platform add ios
I have faced same problem, then upgraded Cordova to 7.1.0 work for me
From my ionic project I did (bash):
grep -r 'platform_metadata' .
and found I had a plugin called cordova-plugin-swift-support was the culprit. I removed it and then added cordova-plugin-add-swift-support back in, and everything worked fine with cordova 8.0.0

Cordova Reading build config file error: Cannot read property 'name' of undefined

I'm using Cordova (7.0.1) and after I'm executing
cordova run ios "--target=iPhone-7, 10.3"
I'm getting error
MAC:folder user$ cordova run ios "--target=iPhone-7, 10.3"
Reading build config file: Error: Cannot read property 'name' of undefined
However, after I'm executing
cordova run ios "--target=iPhone-7, 10.3"
Everything works just fine. 'Verbose' doesn't help really.
I thought that the issue is connected with this issue, so I tried to do
cd platforms/ios/cordova/node_modules/
sudo npm install -g ios-sim#latest
But no luck.
Any ideas why it doesn't work if I specify iOS version and how to fix it?
Do I need to put a 'name' property somewhere or it's just a bug?
Node : 8.1.4
npm : 5.4.1
ios-deploy : 1.9.2
ios-sim : 6.0.0
OS : 10.12.6
Xcode : 8.3.3 (8E3004b)
Looks like this is my issue: issues.apache.org: cordova emulate ios with --target throws undefined error
Guys from Apache are saying that it was fixed in cordova-ios#4.5.0
So this solved my issue
npm i -g cordova-ios#latest
However is going to do that - please make sure do it not only for global, but for local project too. i.e.
npm i cordova-ios#latest
I hope it helps. 🙂

How to fix Failed to fetch platform cordova-ios#~4.4.0

When I use the "cordova platform add ios" command for the latest Cordova version which is 7.0.1, I receive a failed to fetch message.
I am trying to upgrade an existing project to iOS version 4.4.0 but for my peace of mind, I tried creating a fresh project which also had the same error.
Here is my terminal output below showing the errors I receive, can anyone recommend a solution to resolve this issue?
Stuarts-MacBook-Pro:T Stu$ cordova create myApp org.apache.cordova.myApp myApp
Creating a new cordova project.
Stuarts-MacBook-Pro:T Stu$ cd myApp
Stuarts-MacBook-Pro:myApp Stu$ cordova platform add ios
Using cordova-fetch for cordova-ios#~4.4.0
Error: Failed to fetch platform cordova-ios#~4.4.0
Probably this is either a connection problem, or platform spec is incorrect.
Check your connection and platform name/version/URL.
Failed to get absolute path to installed module
Stuarts-MacBook-Pro:myApp Stu$ cordova platform add ios
Using cordova-fetch for cordova-ios#^4.4.0
Error: Failed to fetch platform cordova-ios#^4.4.0
Probably this is either a connection problem, or platform spec is incorrect.
Check your connection and platform name/version/URL.
Error: npm: Command failed with exit code 254 Error output:
npm WARN org.apache.cordova.myapp#1.0.0 No repository field.
npm ERR! Darwin 16.0.0
npm ERR! argv "/usr/local/Cellar/node/6.2.0/bin/node" "/usr/local/bin/npm" "install" "cordova-ios#^4.4.0" "--save"
npm ERR! node v6.2.0
npm ERR! npm v3.8.9
npm ERR! path /Users/S/Development/T/myApp/node_modules/.staging/xml-escape-d330e1e1
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall rename
npm ERR! enoent ENOENT: no such file or directory, rename '/Users/S/Development/T/myApp/node_modules/.staging/xml-escape-d330e1e1' -> '/Users/S/Development/T/myApp/node_modules/cordova-ios/node_modules/xml-escape'
I have resolved this, it appears to be an NPM issue and not a Cordova one. I just updated NPM within Terminal and after the update "cordova platform add ios" worked fine. Happy days - 1 !
npm update -g
Delete the folder cordova-ios, located in node_modules/cordova-ios.
Type the following command
ionic cordova build ios
Sometimes a previously added Platform is not removed Properly, so this type of issue occurs. Remove the platform by command and add it again..
Follow this steps:
Run the command
ionic cordova platform remove ios
Run the command:
ionic cordova platform add ios --save
If you are still getting the issue, try running again:
ionic cordova platform remove ios --save
NOTE: By running again the command ionic cordova platform remove ios --save fetches newer version of ios platform.
For example:
First time: cordova-fetch for cordova-ios#~4.5.1
Second time: cordova-fetch for cordova-ios#~4.5.4

Installing plugins keeps failing because of es6-prepare-plugin

I am trying to prepare my iOS app and I need to get socialsharing and the whitelist plugin working, but they do not work. For example, when I do this:
sudo cordova plugin add cordova-plugin-x-socialsharing
I get this:
Installing "cordova-plugin-x-socialsharing" for android
Failed to install 'cordova-plugin-x-socialsharing':
CordovaError:
Failed to fetch plugin es6-promise-plugin 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! code ENOLOCAL npm ERR!
Could not install from "node_modules/es6-promise-plugin" as it does
not contain a package.json file.
npm ERR!
How can I fix this? I tried everything. From sudo to non-sudo commands, but nothing is working for me. Adding es6-prepare-plugin manually does not work either.
My system information:
Cordova CLI: 7.0.1
Gulp version: CLI version 3.9.1
Gulp local: Local version 3.9.1
Ionic Framework Version: 1.3.3
Ionic CLI Version: 2.1.0
Ionic App Lib Version: 2.1.0-beta.1
ios-deploy version: 1.9.0
ios-sim version: 5.0.8
OS: Mac OS X El Capitan
Node Version: v6.8.1
Xcode version: Xcode 8.3.3 Build version 8E3004b
PS: in my package.json file, I see this:
"es6-promise-plugin": "file:node_modules/es6-promise-plugin",
How can I change this?
Oh dear Lord. I found the answer I was looking for, after I've struggled for hours. This link on Github is the answer to this problem.
Seems like npm version 5.x.x does not work with some ionic-plugins. I downgraded to npm 4 using npm install -g npm#4.6.1 and installing this plugin worked for me afterwards.
Ionic is so buggy sometimes. Very annoying.

IONIC:Unable to install phonegap-plugin-push in ios app

I am new with ionic framework.Currently i am working on ionic iOS app. when i install phonegap-plugin-push i am getting error
Failed to install 'phonegap-plugin-push':undefined Error: /Library/Ruby/Gems/2.0.0/gems/claide-1.0.1/lib/claide/command.rb:439:in `help!': [!] You cannot run CocoaPods as root. (CLAide::Help)
i have searched it but no solution found yet!
I also got same kind of problem. In my case I used sudo ionic platform add ios
This is worked well while building every plugins but phonegap-plugin-push.
phonegap-plugin-push is keep giving above error [!] You cannot run CocoaPods as root. (CLAide::Help)
Then I used ionic platform add ios without sudo This is the actual solution for this. But in this case It is keep giving me the permission related issue code EACCESS.
Then I used followings step to overcome that one.
sudo chown -R $USER /usr/local/
Again added cordoava and ionic
sudo npm install -g cordova
sudo npm install -g ionic
Other informations
phonegap-plugin-push version: 1.10.0
Cordova CLI: 6.5.0
Ionic CLI Version: 2.2.2
Node Version: v7.7.2
Xocde Version: Xcode 8.2.1
CocoaPods Version: 1.2.0
Hope this will help.

Resources