我正在尝试将ionic 2 app连接到backand并获得此运行时错误:
找不到模块“离子原生” .
我试过运行 npm install @ionic-native/core --save
- 但没有帮助 . 非常感谢
设置详细信息:Ionic Framework:3.0.1 Ionic App脚本:1.3.0 Angular Core:4.0.0 Angular Compiler CLI:4.0.0节点:6.10.1 OS平台:Windows 10 Navigator平台:Win32用户代理: Mozilla / 5.0(Windows NT 10.0; Win64; x64)AppleWebKit / 537.36(KHTML,与Gecko一样)Chrome / 57.0.2987.133 Safari / 537.36错误:无法在g找到模块“ionic-native”(localhost:8100 / build / polyfills . js:3:7133)在Object处的webpack_require(localhost:8100 / build / main.js:20:30)处的Object.module.exports(localhost:8100 / build / main.js:114616:7)处 . (localhost:8100 / build / main.js:86362:73)at object的webpack_require(localhost:8100 / build / main.js:20:30) . (localhost:8100 / build / main.js:140153:70)at webpack_require(localhost:8100 / build / main.js:20:30)at localhost:8100 / build / main.js:66:18
Package.Json
如下:
{
"name": "ionic-hello-world",
"author": "Ionic Framework",
"homepage": "http://ionicframework.com/",
"private": true,
"scripts": {
"clean": "ionic-app-scripts clean",
"build": "ionic-app-scripts build",
"ionic:build": "ionic-app-scripts build",
"ionic:serve": "ionic-app-scripts serve"
},
"dependencies": {
"@angular/common": "4.0.0",
"@angular/compiler": "4.0.0",
"@angular/compiler-cli": "4.0.0",
"@angular/core": "4.0.0",
"@angular/forms": "4.0.0",
"@angular/http": "4.0.0",
"@angular/platform-browser": "4.0.0",
"@angular/platform-browser-dynamic": "4.0.0",
"@ionic-native/core": "3.4.2",
"@ionic-native/splash-screen": "3.4.2",
"@ionic-native/status-bar": "3.4.2",
"@ionic/storage": "2.0.1",
"ionic-angular": "3.0.1",
"ionicons": "3.0.0",
"rxjs": "5.1.1",
"socket.io-client": "^1.7.3",
"sw-toolbox": "3.4.0",
"zone.js": "^0.8.4"
},
"devDependencies": {
"@ionic/app-scripts": "1.3.0",
"@types/node": "7.0.13",
"@types/socket.io-client": "1.4.29",
"typescript": "~2.2.1"
},
"cordovaPlugins": [
"cordova-plugin-whitelist",
"cordova-plugin-statusbar",
"cordova-plugin-console",
"cordova-plugin-device",
"cordova-plugin-splashscreen",
"ionic-plugin-keyboard",
"cordova-plugin-inappbrowser"
],
"cordovaPlatforms": [],
"description": "myApp: An Ionic project"
}
2 回答
这个问题与旧的导入'离子原生'有关
就我而言:从'ionic-native'导入{StatusBar,Splashscreen};我删除并添加了新的:
https://ionicframework.com/docs/native/status-bar https://ionicframework.com/docs/native/splash-screen
如果这也是您的情况,请不要忘记在模块提供程序中添加
使用Ionic 3,离子原生模块现在作为提供者加载 . 见以下链接:
https://github.com/driftyco/ionic/blob/master/CHANGELOG.md
http://blog.ionic.io/ionic-native-3-x/
https://github.com/driftyco/ionic-conference-app/commit/62088
因此,如果要使用任何本机功能,则必须升级代码 .