angular – 找不到’ramda’的类型定义文件
我有一个Ionic 2& Angular 2.
我在我的代码中使用RamdaJS,这完全适用于这些命令: >离子服务 但是当我尝试执行这个命令时:离子cordova构建android –prod –release,我得到一个关于Ramda和Type的错误. 看看我的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 } } 尝试构建生产时出错: [12:26:31] typescript error Cannot find type definition file for 'ramda'. Error: Failed to transpile TypeScript 解决方法
按照
DefinitlyTyped的建议,通过@ types / packageName安装类型.
对于NPM做: npm install @types/ramda --save-dev 对于YARN使用: yarn add @types/ramda --dev 在缺少node_modules中名为@types的directiory,Typescript会查找类型定义:
tsconfig.json docs (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |