生产中的离子 - 字段“浏览器”不包含有效的别名配置

时间:2018-01-02 10:37:42

标签: angular typescript ionic-framework webpack ngx-translate

我正在尝试创建我的Ionic应用程序的生产apk,当我运行命令时出现以下错误:

离子cordova build --prod --release --optimizejs --minifyjs --minifycss android

 @ ./src/app/main.ts,./src/app/app.module.ngfactory.js
Module not found: Error: Can't resolve '@ngx-translate/core/src/translate.store' in '/home/hudson/projetos/brazil-cartoon/brazil-cartoon-app/src/app'
resolve '@ngx-translate/core/src/translate.store' in '/home/hudson/projetos/brazil-cartoon/brazil-cartoon-app/src/app'
Parsed request is a module
using description file: /home/hudson/projetos/brazil-cartoon/brazil-cartoon-app/package.json (relative path: ./src/app)
Field 'browser' doesn't contain a valid alias configuration
after using description file: /home/hudson/projetos/brazil-cartoon/brazil-cartoon-app/package.json (relative path: ./src/app)
resolve as module
  looking for modules in /home/hudson/projetos/brazil-cartoon/brazil-cartoon-app/node_modules
    using description file: /home/hudson/projetos/brazil-cartoon/brazil-cartoon-app/package.json (relative path: ./node_modules)
      Field 'browser' doesn't contain a valid alias configuration
    after using description file: /home/hudson/projetos/brazil-cartoon/brazil-cartoon-app/package.json (relative path: ./node_modules)
      using description file: /home/hudson/projetos/brazil-cartoon/brazil-cartoon-app/node_modules/@ngx-translate/core/package.json (relative path: ./src/translate.store)
        no extension
          Field 'browser' doesn't contain a valid alias configuration
          /home/hudson/projetos/brazil-cartoon/brazil-cartoon-app/node_modules/@ngx-translate/core/src/translate.store doesn't exist
        .ts
          Field 'browser' doesn't contain a valid alias configuration
          /home/hudson/projetos/brazil-cartoon/brazil-cartoon-app/node_modules/@ngx-translate/core/src/translate.store.ts doesn't exist
        .js
          Field 'browser' doesn't contain a valid alias configuration
          /home/hudson/projetos/brazil-cartoon/brazil-cartoon-app/node_modules/@ngx-translate/core/src/translate.store.js doesn't exist
        .json
          Field 'browser' doesn't contain a valid alias configuration
          /home/hudson/projetos/brazil-cartoon/brazil-cartoon-app/node_modules/@ngx-translate/core/src/translate.store.json doesn't exist
        as directory
          /home/hudson/projetos/brazil-cartoon/brazil-cartoon-app/node_modules/@ngx-translate/core/src/translate.store doesn't exist

在我看来问题出在@ ngx-translate上。它正在开发中正确地工作,这正在我正在为生产而建立。

这是我的package.json:

的一部分
{
    "dependencies": {
        "@angular/common": "5.0.1",
        "@angular/compiler": "5.0.1",
        "@angular/compiler-cli": "5.0.1",
        "@angular/core": "5.0.1",
        "@angular/forms": "5.0.1",
        "@angular/http": "5.0.1",
        "@angular/platform-browser": "5.0.1",
        "@angular/platform-browser-dynamic": "5.0.1",
        "@ionic-native/camera": "4.4.2",
        "@ionic-native/core": "4.4.2",
        "@ionic-native/date-picker": "4.4.2",
        "@ionic-native/facebook": "4.4.2",
        "@ionic-native/globalization": "4.4.2",
        "@ionic-native/google-plus": "4.4.2",
        "@ionic-native/onesignal": "4.4.2",
        "@ionic-native/social-sharing": "^4.5.2",
        "@ionic-native/splash-screen": "4.4.2",
        "@ionic-native/status-bar": "4.4.2",
        "@ionic/storage": "^2.1.3",
        "@ngx-translate/core": "^9.0.2",
        "@ngx-translate/http-loader": "^2.0.0",
        "cordova-android": "^6.4.0",
        "cordova-plugin-camera": "^3.0.0",
        "cordova-plugin-compat": "^1.2.0",
        "cordova-plugin-datepicker": "^0.9.3",
        "cordova-plugin-device": "1.1.4",
        "cordova-plugin-facebook4": "^1.9.1",
        "cordova-plugin-file": "^5.0.0",
        "cordova-plugin-file-transfer": "^1.7.0",
        "cordova-plugin-globalization": "^1.0.8",
        "cordova-plugin-googleplus": "^5.1.1",
        "cordova-plugin-ionic-webview": "^1.1.11",
        "cordova-plugin-splashscreen": "~4.0.1",
        "cordova-plugin-whitelist": "1.3.1",
        "cordova-plugin-x-socialsharing": "^5.2.1",
        "cordova-sqlite-storage": "^2.1.2",
        "es6-promise-plugin": "git+https://github.com/vstirbu/PromisesPlugin.git",
        "font-awesome": "^4.7.0",
        "imgcache.js": "^1.1.1",
        "ionic-angular": "3.9.2",
        "ionic-plugin-keyboard": "~2.2.1",
        "ionicons": "3.0.0",
        "messageformat": "^1.1.0",
        "moment": "^2.19.2",
        "ng-jhipster": "^0.3.4",
        "ngx-cookie-service": "^1.0.9",
        "ngx-translate-messageformat-compiler": "^2.1.0",
        "onesignal-cordova-plugin": "^2.2.2",
        "rxjs": "5.5.2",
        "sw-toolbox": "3.6.0",
        "zone.js": "0.8.18"
    },
    "devDependencies": {
        "@ionic/app-scripts": "3.1.5",
        "typescript": "2.4.2"
    },
}

修改

看了更多关注的错误信息之后,我验证了@ ngx-translate / core的src文件夹只包含* .d.ts文件:

ngx-translate

这个文件夹不应该有* js文件吗?有解决方法吗?

1 个答案:

答案 0 :(得分:0)

问题是@ ngx-translate / core文件夹中没有* .js文件。为了解决这个问题,我决定删除已安装的版本并直接使用git repository添加依赖项:

纱线添加https://github.com/ngx-translate/core