I have a project with Ionic
2 & Angular
2.
I use RamdaJS in my code, this is perfectly working with these commands:
ionic serve
ionic cordova build android
ionic cordova run android
But when I try to execute this command: ionic cordova build android --prod --release
, I got an error about Ramda and Type.
See a part of my package.json
:
"dependencies": {
"@angular/common": "2.4.8",
"@angular/compiler": "2.4.8",
"@angular/compiler-cli": "2.4.8",
"@angular/core": "2.4.8",
"@angular/flex-layout": "^2.0.0-rc.1",
"@angular/forms": "2.4.8",
"@angular/http": "2.4.8",
"@angular/material": "2.0.0-beta.2",
"@angular/platform-browser": "2.4.8",
"@angular/platform-browser-dynamic": "2.4.8",
"@angular/platform-server": "2.4.8",
"@angular/router": "3.4.8",
"@ionic-native/camera": "3.7.0",
"@ionic-native/core": "3.7.0",
"@ionic-native/network": "3.7.0",
"@ionic-native/splash-screen": "3.7.0",
"@ionic-native/status-bar": "3.7.0",
"@ionic/storage": "2.0.0",
"cordova-plugin-device": "^2.0.1",
"cordova-plugin-ionic-keyboard": "^2.0.5",
"cordova-plugin-ionic-webview": "^1.1.16",
"cordova-plugin-splashscreen": "^5.0.2",
"cordova-plugin-whitelist": "^1.3.3",
"hammerjs": "2.0.8",
"ionic-angular": "2.3.0",
"ionicons": "3.0.0",
"material-design-icons": "3.0.1",
"moment": "2.18.1",
"moment-duration-format": "1.3.0",
"ng2-translate": "5.0.0",
"ng2-webstorage": "1.5.1",
"ngx-pipes": "1.5.7",
"ramda": "0.23.0",
"rxjs": "5.0.1",
"sw-toolbox": "3.4.0",
"zone.js": "0.7.2",
"cordova-android": "~7.0.0"
},
"devDependencies": {
"@ionic/app-scripts": "1.2.2",
"@types/ramda": "github:types/npm-ramda",
"@types/moment-duration-format": "1.3.1",
"typescript": "2.2.1"
}
tsconfig.json
{
"compilerOptions": {
"baseUrl": "./",
"paths" : {
"ramda": [
"location-of-types/npm-ramda-package/index"
]
},
"allowSyntheticDefaultImports": true,
"declaration": false,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"lib": [
"dom",
"es2015"
],
"module": "es2015",
"moduleResolution": "node",
"sourceMap": true,
"target": "es5"
},
"include": [
"src/**/*.ts"
],
"exclude": [
"node_modules"
],
"compileOnSave": false,
"atom": {
"rewriteTsconfig": false
}
}
Error when trying to build for production:
[12:26:31] typescript error
Cannot find type definition file for 'ramda'.
Error: Failed to transpile TypeScript
Install the types via @types/packageName
as recommended by DefinitlyTyped.
For NPM do:
npm install @types/ramda --save-dev
For YARN use:
yarn add @types/ramda --dev
Typescript looks by default for a directiory named @types
inside your node_modules
to find type definitions:
By default all visible “@types” packages are included in your compilation. Packages in node_modules/@types of any enclosing folder are considered visible; specifically, that means packages within ./node_modules/@types/, ../node_modules/@types/, ../../node_modules/@types/, and so on.
If typeRoots is specified, only packages under typeRoots will be included.
tsconfig.json docs
Follow the install instructions here: https://github.com/types/npm-ramda
# using npm npm install --save-dev types/npm-ramda#dist
If not using npm/yarn, you may need to add these typings to paths in tsconfig.json:
For the full package:
{ "compilerOptions": { "baseUrl": "./", "paths" : { "ramda": [ "location-of-types/npm-ramda-package/index" ] } } }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With