Error: Cannot find module 'semver' - ionic-framework

I was working on a simple Ionic App.
Steps taken:
updated ionic - OK
started new project - OK
created a couple of pages- OK
served the app - OK
but then I tried to add the android platform:
ionic platform add android
and got this error:
ERROR: Cannot find module 'semver'
at Function.Module._resolveFilename (module.js:336:15)
Caught exception:
undefined
Any idea on why I'm getting this error and how to fix it?
Thanks!

i faced same issue and i fix with below coment
sudo rm -rf node_modules/ package-lock.json

Looks like you're just missing a node module dependency. Try running npm install semver inside your project dir.

Related

The target entry-point "#ionic-native/media-capture" has missing dependencies: - #ionic-native/core

When I try to build my ionic mobile app on android I get the following error.
An error occurred during the build:
Error: The target entry-point "#ionic-native/media-capture" has missing dependencies:
- #ionic-native/core
at TargetedEntryPointFinder.findEntryPoints (/Users/prabhashibuddhima/Documents/Personal/Projects/VRec/myVideo/node_modules/#angular/compiler-cli/ngcc/src/entry_point_finder/targeted_entry_point_finder.js:40:23)
at /Users/prabhashibuddhima/Documents/Personal/Projects/VRec/myVideo/node_modules/#angular/compiler-cli/ngcc/src/execution/analyze_entry_points.js:28:41
at SingleProcessExecutorSync.SingleProcessorExecutorBase.doExecute (/Users/prabhashibuddhima/Documents/Personal/Projects/VRec/myVideo/node_modules/#angular/compiler-cli/ngcc/src/execution/single_process_executor.js:28:29)
at /Users/prabhashibuddhima/Documents/Personal/Projects/VRec/myVideo/node_modules/#angular/compiler-cli/ngcc/src/execution/single_process_executor.js:57:59
at SyncLocker.lock (/Users/prabhashibuddhima/Documents/Personal/Projects/VRec/myVideo/node_modules/#angular/compiler-cli/ngcc/src/locking/sync_locker.js:34:24)
at SingleProcessExecutorSync.execute (/Users/prabhashibuddhima/Documents/Personal/Projects/VRec/myVideo/node_modules/#angular/compiler-cli/ngcc/src/execution/single_process_executor.js:57:27)
at Object.mainNgcc (/Users/prabhashibuddhima/Documents/Personal/Projects/VRec/myVideo/node_modules/#angular/compiler-cli/ngcc/src/main.js:74:25)
at Object.process (/Users/prabhashibuddhima/Documents/Personal/Projects/VRec/myVideo/node_modules/#angular/compiler-cli/ngcc/index.js:29:23)
at NgccProcessor.processModule (/Users/prabhashibuddhima/Documents/Personal/Projects/VRec/myVideo/node_modules/#ngtools/webpack/src/ngcc_processor.js:163:16)
at /Users/prabhashibuddhima/Documents/Personal/Projects/VRec/myVideo/node_modules/#ngtools/webpack/src/ivy/host.js:55:18
at /Users/prabhashibuddhima/Documents/Personal/Projects/VRec/myVideo/node_modules/#ngtools/webpack/src/ivy/host.js:47:24
at Array.map (<anonymous>)
at Object.host.resolveModuleNames (/Users/prabhashibuddhima/Documents/Personal/Projects/VRec/myVideo/node_modules/#ngtools/webpack/src/ivy/host.js:45:32)
at actualResolveModuleNamesWorker (/Users/prabhashibuddhima/Documents/Personal/Projects/VRec/myVideo/node_modules/typescript/lib/typescript.js:102904:133)
at resolveModuleNamesWorker (/Users/prabhashibuddhima/Documents/Personal/Projects/VRec/myVideo/node_modules/typescript/lib/typescript.js:103126:26)
at resolveModuleNamesReusingOldState (/Users/prabhashibuddhima/Documents/Personal/Projects/VRec/myVideo/node_modules/typescript/lib/typescript.js:103200:24)
An unhandled exception occurred: The target entry-point "#ionic-native/media-capture" has missing dependencies:
- #ionic-native/core
See "/private/var/folders/vp/8s5chkws6tx5v3wjyvr7n_qm0000gn/T/ng-HBL1kz/angular-errors.log" for further details.
I’m getting this error not only with the media-capture plugin. With Image-picker, file plugins also I’m getting the same error. I tried recreating the project, removing platforms and plugins and adding them again, npm install and all.
Please help me to solve this
It seems that you miss the #ionic-native/core dependency.
You need to run npm install --save #ionic-native/core to install it.
If the problem persists, try to delete the node_modules folder, and run npm install again.
the error means that you have installed #ionic-native/media-capture but it is lacking #ionic-native/core dependence which you need to install
by running this command:
npm i #ionic-native/core --save

IONIC 5 ionic serve produces Error: NGCC failed

I created a new ionic 5 project by using
ionic start myApp blank
When I run the project in browser using ionic serve it has given the following error
Error: NGCC failed
I figured out the problem my self
The problem was when I was installing the latest npm packages
it was installing the typescript: 4.0.2 and thats why the NGCC error
occured
run the following command and it will work,
npm i typescript#">=3.9.2 <4.0.0”
Or in future some one faces this error this is about the typescript version so just install the valid typescript and you will fix the ngcc error

Ionic4 Unknown browser query

I have practised Ionic a lot so these Problems are not new for me but I am unabale to solve this one.
I am currently trying to migrate my Ionic3 project to Ionic4.
To do this I have created a new Ionic4 tabs project.
Every time I try the Ionic serve command I am getting:
[ng] An unhandled exception occurred: Unknown browser query
basedir=$(dirname "$(echo "$0" | sed -e 's
Maybe you are using old Browserslist or made typo in query.
[ng] See "C:\Users\Admin\AppData\Local\Temp\ng-9er5Id\angular-errors.log" for further details.
[ERROR] ng has unexpectedly closed (exit code 127).
The Log file:
[error] BrowserslistError: Unknown browser query `basedir=$(dirname "$(echo "$0" | sed -e 's`. Maybe you are using old Browserslist or made typo in query.
at unknownQuery (D:\Wisex\Technik\Client\safehome_client\node_modules\browserslist\index.js:204:10)
at D:\Wisex\Technik\Client\safehome_client\node_modules\browserslist\index.js:296:11
at Array.reduce (<anonymous>)
at resolve (D:\Wisex\Technik\Client\safehome_client\node_modules\browserslist\index.js:237:18)
at browserslist (D:\Wisex\Technik\Client\safehome_client\node_modules\browserslist\index.js:361:16)
at new BuildBrowserFeatures (D:\Wisex\Technik\Client\safehome_client\node_modules\#angular-devkit\build-angular\src\utils\build-browser-features.js:17:35)
at generateWebpackConfig (D:\Wisex\Technik\Client\safehome_client\node_modules\#angular-devkit\build-angular\src\utils\webpack-browser-config.js:24:34)
at process._tickCallback (internal/process/next_tick.js:68:7)
at Function.Module.runMain (internal/modules/cjs/loader.js:834:11)
at startup (internal/bootstrap/node.js:283:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)
Does anyone of you have an possible solution for this.
I am really greatful for help cause I takes my days to migrate by now.
Yours,
Benjamin
Do you have the last version of the angular cli?
npm install -g #angular/cli
It might also be useful to post the log
I have spent several hours to fix this .Hope it will help someone
Kindly follow the below steps:
find your npm path from the environmental variable. And copy that path and paste it in notepad
2.Go to control panel ->uninstall the node js
3.after uninstalling,restart the system.
4.Now go to npm path in file explorer.
5.And delete the folder named npm and npm-cache
6.And now install the node(LTS version) and angular(refer from the below link for step by step installation)
https://www.zeolearn.com/magazine/setup-angular-windows
note:Dont run the cmd as administrator.Unless ,the installation fails
7.Once you verified that angular is running fine using ng serve -o
8.Install the ionic by npm install -g ionic#latest
9.And run ionic serve.
10.Hope it helps.Happy coding :)

Ionic ERROR: version.json FILE_NOT_FOUND

I am new to ionic. Can anyone please help me solve the following error:
[WARN] Error with .\WWW\lib\ionic\version.json file: FILE_NOT_FOUND, trying .\bower .json
This worked for me, just run the following within the ionic repo:
rm -rf resources/android
ionic cordova resources

ionic 2 error when start new project

E:\SocialLoginDemo>ionic start HelloWorld12 blank --v2
Creating Ionic app in folder E:\SocialLoginDemo\HelloWorld12 based on blank project
Installing npm packages...
Error with start undefined
Error Initializing app: There was an error with the spawned command: npminstall
There was an error with the spawned command: npminstall
Caught exception:
undefined
Mind letting us know? https://github.com/driftyco/ionic-cli/issues
my version information
Your system information:
You have been opted out of telemetry. To change this, run: cordova
telemetry on.
6.3.1
Ionic CLI Version:2.1.0
Ionic App Lib Version: 2.1.0-beta.1
OS: Node Version:v4.6.0
There was some problem in spawned command "npminstall" but now they have fixed this issue. Mostly it should work now and if not kindly share screenshot of errors being thrown.