我能够构建一个离子应用程序。当我尝试为 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 at BuildError.Error (native) at new BuildError (/Users/karthikcp/Documents/IONIC/CIS/node_modules/@ionic/app-scripts/dist/util/errors.js:16:28) at callback (/Users/karthikcp/Documents/IONIC/CIS/node_modules/@ionic/app-scripts/dist/webpack.js:121:28) at emitRecords.err (/Users/karthikcp/Documents/IONIC/CIS/node_modules/webpack/lib/Compiler.js:265:13) at Compiler.emitRecords (/Users/karthikcp/Documents/IONIC/CIS/node_modules/webpack/lib/Compiler.js:371:38) at emitAssets.err (/Users/karthikcp/Documents/IONIC/CIS/node_modules/webpack/lib/Compiler.js:258:10) at applyPluginsAsyncSeries1.err (/Users/karthikcp/Documents/IONIC/CIS/node_modules/webpack/lib/Compiler.js:364:12) at next (/Users/karthikcp/Documents/IONIC/CIS/node_modules/tapable/lib/Tapable.js:218:11) at Compiler.compiler.plugin (/Users/karthikcp/Documents/IONIC/CIS/node_modules/webpack/lib/performance/SizeLimitsPlugin.js:99:4) at Compiler.applyPluginsAsyncSeries1 (/Users/karthikcp/Documents/IONIC/CIS/node_modules/tapable/lib/Tapable.js:222:13)
我正在使用最新的Ionic版本,当不使用--prod
时,我能够构建它。请帮助我..我是离子的新手
我通过删除node_modules,package-lock.json
解决了这个问题。更新了包.json:
"devDependencies": {
"@ionic/app-scripts": "nightly",
"typescript": "2.4.2"
},
并重新运行
npm 安装