解决 ionic打包apk 报错 Unexpected token e in JSON at position 0

D:\project\app_jianshang>ionic cordova run android
√ Creating .\www directory for you - done!
SyntaxError: Unexpected token e in JSON at position 0

at JSON.parse (<anonymous>)
at Object.getNativeTargets (C:\Users\Administrator\AppData\Roaming\npm\node_modules\ionic\lib\native-run.js:109:44)

开始以为是config.xml和androidManifest.xml中的配置多了特殊字符引起的错误

加上--verbose执行

D:\project\app_jianshang>ionic cordova run android --verbose
  ionic:lib Terminal info: { ci: false, shell: 'C:\\Windows\\system32\\cmd.exe', tty: true, windows: true } +0ms
  ionic:lib CLI global options: { _: [ 'cordova', 'run', 'android' ], help: null, h: null, verbose: true, quiet: null, interactive: true, color: true, confirm: null, json: null, project: null, '--': [] } +7ms
  ionic:lib:project Project type from config: @ionic/angular (angular) +0ms
  ionic:lib:project Project details: { configPath: 'D:\\project\\app_jianshang\\ionic.config.json', errors: [], context: 'app', type: 'angular' } +2ms
  ionic Context: { binPath: 'C:\\Users\\Administrator\\AppData\\Roaming\\npm\\node_modules\\ionic\\bin\\ionic', libPath: 'C:\\Users\\Administrator\\AppData\\Roaming\\npm\\node_modules\\ionic', execPath: 'D:\\project\\app_jianshang', version: '5.4.16' } +0ms
  ionic:lib:integrations:cordova:config Loading Cordova Config (config.xml: 'D:\\project\\app_jianshang\\config.xml', package.json: 'D:\\project\\app_jianshang\\package.json') +0ms
SyntaxError: Unexpected number in JSON at position 4

at JSON.parse (<anonymous>)
at Object.getNativeTargets (C:\Users\Administrator\AppData\Roaming\npm\node_modules\ionic\lib\native-run.js:109:44)
  ionic SyntaxError: Unexpected number in JSON at position 4
  ionic     at JSON.parse (<anonymous>)
  ionic     at Object.getNativeTargets (C:\Users\Administrator\AppData\Roaming\npm\node_modules\ionic\lib\native-run.js:109:44) +17s

将文件还原之后 重启了vscode

在执行ionic cordova run android --verbose

我们可以看到 Unexpected number in JSON at position 4

有无法解析的数字在第4个位置

使用beyondcompare或者比较工具比较config.xml 以及 package.json 还有androidManifest.xml这几个文件值

 

已标记关键词 清除标记
©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页