【问题标题】:Cannot build IONIC iOS --prod showing error无法构建 IONIC iOS --prod 显示错误
【发布时间】:2018-06-10 12:04:24
【问题描述】:

我能够构建一个离子应用程序。当我尝试为 iOS 构建生产版本时:

ionic cordova build ios --prod

它显示以下错误:

错误:./src/app/main.ts 找不到模块:错误:无法解析“/Users/karthikcp/Documents/IONIC/CIS/src/app”中的“./app.module.ngfactory” 在“/Users/karthikcp/Documents/IONIC/CIS/src/app”中解析“./app.module.ngfactory” 使用描述文件:/Users/karthikcp/Documents/IONIC/CIS/package.json(相对路径:./src/app) 字段“浏览器”不包含有效的别名配置 使用描述文件后:/Users/karthikcp/Documents/IONIC/CIS/package.json(相对路径:./src/app) 使用描述文件:/Users/karthikcp/Documents/IONIC/CIS/package.json(相对路径:./src/app/app.module.ngfactory) 没有扩展 字段“浏览器”不包含有效的别名配置 /Users/karthikcp/Documents/IONIC/CIS/src/app/app.module.ngfactory 不存在 .ts 字段“浏览器”不包含有效的别名配置 /Users/karthikcp/Documents/IONIC/CIS/src/app/app.module.ngfactory.ts 不存在 .js 字段“浏览器”不包含有效的别名配置 /Users/karthikcp/Documents/IONIC/CIS/src/app/app.module.ngfactory.js 不存在 .json 字段“浏览器”不包含有效的别名配置 /Users/karthikcp/Documents/IONIC/CIS/src/app/app.module.ngfactory.json 不存在 作为目录 /Users/karthikcp/Documents/IONIC/CIS/src/app/app.module.ngfactory 不存在 [/Users/karthikcp/Documents/IONIC/CIS/src/app/app.module.ngfactory] [/Users/karthikcp/Documents/IONIC/CIS/src/app/app.module.ngfactory.ts] [/Users/karthikcp/Documents/IONIC/CIS/src/app/app.module.ngfactory.js] [/Users/karthikcp/Documents/IONIC/CIS/src/app/app.module.ngfactory.json] [/Users/karthikcp/Documents/IONIC/CIS/src/app/app.module.ngfactory] @ ./src/app/main.ts 2:0-60 在 BuildError.Error (本机) 在新的 BuildError (/Users/karthikcp/Documents/IONIC/CIS/node_modules/@ionic/app-scripts/dist/util/errors.js:16:28) 在回调(/Users/karthikcp/Documents/IONIC/CIS/node_modules/@ionic/app-scripts/dist/webpack.js:121:28) 在 emitRecords.err (/Users/karthikcp/Documents/IONIC/CIS/node_modules/webpack/lib/Compiler.js:265:13) 在 Compiler.emitRecords (/Users/karthikcp/Documents/IONIC/CIS/node_modules/webpack/lib/Compiler.js:371:38) 在 emitAssets.err (/Users/karthikcp/Documents/IONIC/CIS/node_modules/webpack/lib/Compiler.js:258:10) 在 applyPluginsAsyncSeries1.err (/Users/karthikcp/Documents/IONIC/CIS/node_modules/webpack/lib/Compiler.js:364:12) 在下一个(/Users/karthikcp/Documents/IONIC/CIS/node_modules/tapable/lib/Tapable.js:218:11) 在 Compiler.compiler.plugin (/Users/karthikcp/Documents/IONIC/CIS/node_modules/webpack/lib/performance/SizeLimitsPlugin.js:99:4) 在 Compiler.applyPluginsAsyncSeries1 (/Users/karthikcp/Documents/IONIC/CIS/node_modules/tapable/lib/Tapable.js:222:13)

我正在使用最新的 Ionic 版本当不使用 --prod 时,我可以构建它..请帮助我..我是 IONIC 的新手

【问题讨论】:

    标签: cordova ionic2


    【解决方案1】:

    我通过删除node_modules,package-lock.json 解决了这个问题。将 package.json 更新为:

    "devDependencies": {
        "@ionic/app-scripts": "nightly",
        "typescript": "2.4.2"
      },
    

    然后重新运行

    npm 安装

    【讨论】: