I want to use the cordova file transfer plugin. I'm using it through the Ionic-Native transfer module.
The app won't run because there is a transpile error with the file transfer plugin and the file plugin:
transpile started ...
typescript: plugins/cordova-plugin-file-transfer/types/index.d.ts, line: 9
Cannot find type definition file for 'cordova-plugin-file'.
L8: * #param server URL of the server to receive the file, as encoded by encodeURI().
L9: * #param successCallback A callback that is passed a FileUploadResult object.
L10: * #param errorCallback A callback that executes if an error occurs retrieving the FileUploadResult.
I installed #types/cordova-plugin-file through npm, but the app won't run because of duplicate identifiers in the two cordova-plugin-file packages:
transpile started ...
typescript: node_modules/#types/cordova-plugin-file/index.d.ts, line: 376
Duplicate identifier 'PERSISTENT'.
typescript: node_modules/#types/cordova-plugin-file/index.d.ts, line: 377
Duplicate identifier 'TEMPORARY'.
typescript: plugins/cordova-plugin-file/types/index.d.ts, line: 376
Duplicate identifier 'PERSISTENT'.
typescript: plugins/cordova-plugin-file/types/index.d.ts, line: 377
Duplicate identifier 'TEMPORARY'.
What is the right approach here?
As mentioned, it looks like the typings in cordova-plugin-file-transfer are incorrect.
It should be an external module but it is currently a script file (copied from DefinitelyTyped directly).
On the other hand, since cordova-plugin-file already includes its own typings, you don't need to install #types/cordova-plugin-file.
I experienced this issue as well.
However I was able to work around the issue with the following operations:
Setup :
```
Your system information:
Cordova CLI: 6.5.0
Ionic Framework Version: 2.3.0
Ionic CLI Version: 2.2.1
Ionic App Lib Version: 2.2.0
Ionic App Scripts Version: 1.2.1
ios-deploy version: 1.9.1
ios-sim version: 5.0.13
OS: macOS Sierra
Node Version: v7.7.4
Xcode version: Xcode 8.2.1 Build version 8C1002
```
Initial Problem :
```
$ ionic build ios
Running 'build:before' npm script before build
> apoc# build /Users/js/dev/apoc-ochem/app_v3/apoc
> ionic-app-scripts build
[01:47:59] ionic-app-scripts 1.2.1
[01:47:59] build dev started ...
[01:47:59] clean started ...
[01:47:59] clean finished in 2 ms
[01:47:59] copy started ...
[01:47:59] transpile started ...
[01:48:04] typescript: plugins/cordova-plugin-file-transfer/types/index.d.ts, line: 9
Cannot find type definition file for 'cordova-plugin-file'.
L8: * #param server URL of the server to receive the file, as encoded by encodeURI().
L9: * #param successCallback A callback that is passed a FileUploadResult object.
L10: * #param errorCallback A callback that executes if an error occurs retrieving the FileUploadResult.
[01:48:04] ionic-app-script task: "build"
[01:48:04] Error: Failed to transpile program
Error: Failed to transpile program
at new BuildError (/Users/js/dev/apoc-ochem/app_v3/apoc/node_modules/#ionic/app-scripts/dist/util/errors.js:16:28)
at /Users/js/dev/apoc-ochem/app_v3/apoc/node_modules/#ionic/app-scripts/dist/transpile.js:102:20
at transpileWorker (/Users/js/dev/apoc-ochem/app_v3/apoc/node_modules/#ionic/app-scripts/dist/transpile.js:68:12)
at Object.transpile (/Users/js/dev/apoc-ochem/app_v3/apoc/node_modules/#ionic/app-scripts/dist/transpile.js:26:12)
at buildProject (/Users/js/dev/apoc-ochem/app_v3/apoc/node_modules/#ionic/app-scripts/dist/build.js:98:78)
at /Users/js/dev/apoc-ochem/app_v3/apoc/node_modules/#ionic/app-scripts/dist/build.js:46:16
npm ERR! Darwin 16.4.0
npm ERR! argv "/Users/js/.nvm/versions/node/v7.7.4/bin/node" "/Users/js/.nvm/versions/node/v7.7.4/bin/npm" "run" "build"
npm ERR! node v7.7.4
npm ERR! npm v4.1.2
npm ERR! code ELIFECYCLE
npm ERR! apoc# build: `ionic-app-scripts build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the apoc# build script 'ionic-app-scripts build'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the apoc package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! ionic-app-scripts build
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs apoc
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls apoc
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR!
/Users/js/dev/apoc-ochem/app_v3/apoc/npm-debug.log
```
Steps for Work Around:
Remove Platform
Remove Cordova plugin
Rebuild project
Add Platform
Remove cordova-plugin-file-transfer plugin
Rebuild ios project
```
$ cordova plugin rm cordova-plugin-file-transfer
Removing "cordova-plugin-file-transfer"
$ ionic build ios
...
...
[02:01:20] lint finished in 3.70 s
Error: No platforms added to this project. Please use `cordova platform add <platform>`.
$ ionic platforms add ios
Adding ios project...
Creating Cordova project for the iOS platform:
Path: platforms/ios
Package: com.nielssievertsen.apocsocial
Name: apoc social
iOS project created with cordova-ios#4.3.1
Installing "com.synconset.imagepicker" for ios
Installing "cordova-plugin-camera" for ios
Fetching plugin "cordova-plugin-compat" via npm
Installing "cordova-plugin-compat" for ios
Installing "cordova-plugin-console" for ios
Installing "cordova-plugin-device" for ios
Installing "cordova-plugin-device-motion" for ios
Installing "cordova-plugin-facebook4" for ios
Installing "cordova-plugin-googleplus" for ios
Google Sign-In prerequisites
START Running hook to add iOS Keychain Sharing entitlements (required since iOS 10)
Will add iOS Keychain Sharing entitlements to project 'apoc social'
END Running hook to add iOS Keychain Sharing entitlements (required since iOS 10)
Installing "cordova-plugin-media-capture" for ios
Fetching plugin "cordova-plugin-file" via npm
Installing "cordova-plugin-file" for ios
Dependent plugin "cordova-plugin-compat" already installed on ios.
Dependent plugin "cordova-plugin-compat" already installed on ios.
Installing "cordova-plugin-nativestorage" for ios
Installing "cordova-plugin-shake" for ios
Dependent plugin "cordova-plugin-device-motion" already installed on ios.
Installing "cordova-plugin-splashscreen" for ios
Installing "cordova-plugin-statusbar" for ios
Installing "cordova-plugin-whitelist" for ios
Installing "cordova-sqlite-storage" for ios
installing external dependencies via npm
npm install of external dependencies ok
Installing "ionic-plugin-keyboard" for ios
Installing "phonegap-plugin-push" for ios
Discovered plugin "cordova-plugin-file-transfer" in config.xml. Adding it to the project
Fetching plugin "cordova-plugin-file-transfer#~1.6.1" via npm
Installing "cordova-plugin-file-transfer" for ios
Dependent plugin "cordova-plugin-file" already installed on ios.
$ cordova plugin rm cordova-plugin-file-transfer
Uninstalling cordova-plugin-file-transfer from ios
Removing "cordova-plugin-file-transfer"
"cordova-plugin-file" is required by (cordova-plugin-media-capture) and cannot be removed (hint: use -f or --force)
"cordova-plugin-compat" is required by (cordova-plugin-camera, cordova-plugin-media-capture) and cannot be removed (hint: use -f or --force)
$ ionic build ios
............
...
** BUILD SUCCEEDED **
```
Looks like the typings in cordova-plugin-file-transfer is incorrect.
It should be an external module but it is currently a script file (copied from DefinitelyTyped directly).
You should file an issue there.
On the other hand, since cordova-plugin-file already includes its own typings, you don't need to install #types/cordova-plugin-file.
It seems the "plugin/" folder is cordova plugins for ionic2, which you may not need to perform typescript compilation,
You can always ignore the index.d.ts by specifying the exclude target from tsconfig.json
For Ionic there is file called tsconfig.build.json
in it compiler option add below parameter.
"skipLibCheck": true
it should look like this
{
"extends": "...anytest....",
"compilerOptions": {
"baseUrl": ".",
"target": "es5",
"skipLibCheck": true
},
"exclude": [
"...your config here..."
]
}
Related
Finally after some years of reviewing questions posted by others it's time to write my first one!
Well, I installed Node.js and Cordova (state of the art) as per instructed in this page, but at the beginning I failed to install either platform (iOS or Android).
After many attempts, I decided to give it a last try and run the cordova platform add ios command once again, and incredibly it worked!
Using cordova-fetch for cordova-ios#^5.0.0
Adding ios project...
Creating Cordova project for the iOS platform:
Path: platforms\ios
Package: io.cordova.hellocordova
Name: HelloCordova
iOS project created with cordova-ios#5.1.1
Plugin 'cordova-plugin-whitelist' found in config.xml... Migrating it to package.json
Discovered saved plugin "cordova-plugin-whitelist". Adding it to the project
Installing "cordova-plugin-whitelist" for ios
Adding cordova-plugin-whitelist to package.json
Then, I tried to run cordova platform add android as well, but it failed as usual:
Using cordova-fetch for cordova-android#^8.0.0
Failed to fetch platform cordova-android#^8.0.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 4294963214 Error output:
npm WARN helloworld#1.0.0 No repository field.
npm ERR! code EBUSY
npm ERR! syscall rename
npm ERR! path d:\Dropbox\app\node_modules\.staging\android-versions-697b4c50
npm ERR! dest d:\Dropbox\app\node_modules\android-versions
npm ERR! errno -4082
npm ERR! EBUSY: resource busy or locked, rename 'd:\Dropbox\app\node_modules\.staging\android-versions-697b4c50' -> 'd:\Dropbox\app\node_modules\android-versions'
A complete log of the run is available if needed.
Do you have any clue please?
Needless to say I was running the command prompt as administrator, and the C:\Windows\System32 path is already present in the Environment Windows variable.
Thank you,
Fabio
If i see it correctly, u are working in the Dropbox directory. Dropbox may lock files during its sync operation, which interferes with Cordova. Try moving the app to a folder outside of Dropbox.
I have been trying to use Ionics CLI to regenerate all of the icon and splash images. So I had to install IOS and Android platforms, I installed IOS without a hitch, but installing android has been giving me a problem. Here is what I get after I run this line in Terminal. Any help would be appreciated.
ionic cordova platform add android
Discovered plugin "cordova-plugin-email-composer" in config.xml. Adding it to the project
Failed to restore plugin "cordova-plugin-email-composer" from config.xml. You might need to try adding it again. Error: Failed to fetch plugin https://github.com/katzer/cordova-plugin-email-composer.git#0.8.2 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 ENOPACKAGEJSON
npm ERR! package.json Non-registry package missing package.json: git+https://github.com/katzer/cordova-plugin-email-composer.git#0.8.2.
npm ERR! package.json npm can't find a package.json file in your current directory.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/Fin/.npm/_logs/2018-05-28T14_07_22_673Z-debug.log
Discovered plugin "com.rjfun.cordova.iad" in config.xml. Adding it to the project
Failed to restore plugin "com.rjfun.cordova.iad" from config.xml. You might need to try adding it again. Error: Failed to fetch plugin com.rjfun.cordova.iad#^2.0.4 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 E404
npm ERR! 404 Not Found: com.rjfun.cordova.iad#^2.0.4
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/Fin/.npm/_logs/2018-05-28T14_07_31_437Z-debug.log
Running command: /Users/Fin/fflow/hooks/after_prepare/010_add_platform_class.js /Users/Fin/fflow
Running command: /Users/Fin/fflow/hooks/after_prepare/020_remove_sass_from_platforms.js /Users/Fin/fflow
--save flag or autosave detected
Saving android#~7.0.0 into config.xml file ...
[ERROR] Exception:
--save flag or autosave detected
Saving android#~7.0.0 into config.xml file ...
[ERROR] Exception:
Remove old Platform and then install new Platform
cordova platform remove android
cordova platform add android#7.1.0
I'm trying to understand how to update my Ionic Framework Version.
ionic info
Your system information:
Cordova CLI: 8.0.0
Gulp version: CLI version 3.9.1
Gulp local: Local version 3.9.1
Ionic Framework Version: 1.1.0
Ionic CLI Version: 1.7.16
Ionic App Lib Version: 0.7.3
OS:
Node Version: v6.9.1
So the current Ionic Framework Version is "1.1.0"
I updated my bower.json:
{
"name": "hello-ionic",
"private": "true",
"devDependencies": {
"ionic": "driftyco/ionic-bower#1.3.3"
}
}
and run bower install
but the new files are being stored at 'bower_components' folder
My folder structure:
I also copied the files from 'bower_components' to 'lib' folder and still after ionic info the 'Ionic Framework Version' is still '1.1.0'
Try with
npm install -g ionic#1.3.3
After the CLI has been updated you have a few options when it comes to updating your base library install, goto the root of your project and run this command:
ionic lib update
Here for more details. hope it helps.
Try to upgrade the project to the new versions:
npm install -g ionic#latest
npm install ionic-angular#3.7.0 --save
npm install #ionic/app-scripts#3.0.0 --save-dev
npm install #angular/core#4.4.3 --save
npm install #angular/common#4.4.3 --save
npm install #angular/compiler#4.4.3 --save
npm install #angular/compiler-cli#4.4.3 --save
npm install #angular/forms#4.4.3 --save
npm install #angular/http#4.4.3 --save
npm install #angular/platform-browser#4.4.3 --save
npm install #angular/platform-browser-dynamic#4.4.3 --save
npm install rxjs#5.4.3 --save
npm install zone.js#0.8.17 --save
In addition to improving ionic-angular 3.x.
Also, if you're using animations, run the command:
npm install #angular/animations#4.4.3 --save
It looks like you might actually want
npm update packagename
which does try to honor semver, and does recursively update all the dependencies of packagename. Of course, it does them all recursively asynchronously at once.
If you can give up the need for updating deps-of-deps, then you can get pretty far with
npm --depth 0 update grunt
After a research:
npm will correctly handle version conflicts between shared
dependencies by downloading the correct one for each. So, if Dep A
depends on Dep C v1.0.0 and Dep B depends on Dep C v2.0.0, they will
each be installed and used appropriately. Therefore, you are free to
install the latest of any packages you would like.
Then, feel free to update update package by package or use (AFTER UPDATE YOUR ANGULAR PACKAGES) and exclude for a while the ionic packages from the packages.json to don't update them:
npm i -g npm-check-updates
ncu -u
npm install
The ultimate version of IONIC v1 is 1.3.5, I guess.
You'd better make a global install of ionic, first.
sudo npm i -g ionic
Then, install new Ionic v1 CLI Utility locally for CLI commands as it has been released for v1 project maintenance.
npm i #ionic/v1-toolkit
try command: npm install -g cordova ionic.
simple run
ionic lib update
See official Docs
While the other answers are correct only on updating ionic version with experience I can say you might have old dependencies which might crash with your upgrade so best is to use, https://www.npmjs.com/package/npm-check-updates after installing the package run npx npm-check-updates this will recommend and update all your packages to latest stable.
apk file with a construct two projects exported via Cordova
I open cmd then I reach to my folder with the exported project and when I try to add android using cmd - "cordova platform add android"
I get this:
'Discovered plugin "cordova-custom-config" in config.xml. Adding it to
the project Failed to restore plugin "cordova-custom-config" from
config.xml. You might need to try adding it again. Error: Failed to
fetch plugin cordova-custom-config via registry. Probably this is
either a connection problem, or plugin spec is incorrect. Check your
connection and plugin name/version/URL. Error: cmd: Command failed
with exit code 1 Error output: npm ERR! code ENOGIT npm ERR! No git
binary found in $PATH npm ERR! npm ERR! Failed using git. npm ERR!
Please check if you have git installed and in your PATH.'
Can someone help me?
do this: cordova platform rm android && cordova platform add android
i have error when i run "ionic run android" or "ionic build android" in my ionic 2 app
this is the error i get. i just tryinh to see my app in the emulator of android.
i tried to make new ionic 2 project but it's the same problem.
Running 'build:before' npm script before build
> ionic-hello-world# build C:\Users\Adir\MyApps\tasklist
> ionic-app-scripts build --rollup ./config/rollup.config.js
[20:16:33] ionic-app-scripts 0.0.30
[20:16:33] build prod started ...
[20:16:33] clean started ...
[20:16:33] clean finished in 24 ms
[20:16:33] copy started ...
[20:16:33] ngc started ...
[20:16:33] lint started ...
[20:16:33] copy finished in 182 ms
[20:16:34] lint finished in 770 ms
[20:16:52] ngc finished in 18.71 s
[20:16:52] bundle prod started ...
[20:16:52] bundle prod failed: Could not resolve entry (/app/main.prod.ts)
[20:16:52] Error: Could not resolve entry (/app/main.prod.ts)
at C:\Users\Adir\MyApps\tasklist\node_modules\rollup\dist\rollup.js:8635:28
at process._tickCallback (internal/process/next_tick.js:103:7)
Error running ionic app script "build": Error: Could not resolve entry (/app/main.prod.ts)
npm
ERR! Windows_NT 10.0.14393
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "build"
npm ERR! node v6.7.0
npm ERR! npm v3.10.3
npm ERR! code ELIFECYCLE
npm ERR! ionic-hello-world# build: `ionic-app-scripts build --rollup ./config/rollup.config.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the ionic-hello-world# build script 'ionic-app-scripts build --rollup ./config/rollup.config.js'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the ionic-hello-world package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!
ionic-app-scripts build --rollup ./config/rollup.config.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs ionic-hello-world
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls ionic-hello-world
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! C:\Users\Adir\MyApps\tasklist\npm-debug.log
Caught exception:
undefined
Mind letting us know? https://github.com/driftyco/ionic-cli/issues
C:\Users\Adir\MyApps\tasklist>
This has been a common issue lately with ionic and A2 and resolving main.prod.*Try updating you app scripts for the project.
npm install #ionic/app-scripts#latest
Your error message should change after that with what is actually causing your build to crash. If the error message changes please update your question with the new message.
Checkout this out as well for more information on this issue: Ionic forum
Close all ionic folders and serve or lab. And try again, ionic cordova build android.
First of all, Check the version of Android in package.json file.
Now remove platform with this command (ionic cordova platform rm android)
After that addd the platform with this command (ionic cordova platform add
android#6.4.0). Where 7.0.0 is not stable version so use 6.4.0
Now, run this command (ionic cordova run android) or in mac (sudo ionic cordova run android)
Try out below command
$ cordova clean android
$ cordova build android
$ ionic cordova build android
There is a path setup problem in your system.
1st check npm version using CMD: npm -v
If it shows version number then use below code, otherwise 1st setup your npm path, you can use gitbash cmd, nodejs cmd
Try to use
ionic cordova run android
or
ionic cordova platform remove android
ionic cordova run android
If you have MAC system must use sudo like
sudo ionic cordova run android