无法读取未定义的 属性 'find' (UnhandledPromiseRejectionWarning)
Cannot read property 'find' of undefined (UnhandledPromiseRejectionWarning)
我正在使用 Angular/Firebase 在 Ionic 中构建一个应用程序。
我想在我的 android 设备上测试该应用程序,该设备之前运行良好。但是,最近我无法 运行 它,因为出现错误。
$ ionic cordova run android --device --prod
然后导致错误:
Running app-scripts build: --prod --platform android --target cordova
[15:36:05] build prod started ...
[15:36:05] clean started ...
[15:36:05] clean finished in 6 ms
[15:36:05] copy started ...
[15:36:06] deeplinks started ...
[15:36:06] deeplinks finished in 270 ms
[15:36:06] ngc started ...
[15:36:19] ngc finished in 12.61 s
[15:36:19] preprocess started ...
[15:36:19] preprocess finished in 1 ms
[15:36:19] webpack started ...
[15:36:19] copy finished in 13.84 s
[15:37:27] webpack finished in 68.39 s
[15:37:27] uglify started ...
[15:37:27] sass started ...
Without `from` option PostCSS could generate wrong source map and will not find Browserslist config. Set it to CSS file path or to `undefined` to prevent this warning.
[15:37:29] sass finished in 1.66 s
[15:37:29] cleancss started ...
[15:37:31] cleancss finished in 2.77 s
[15:37:56] uglify finished in 28.99 s
[15:37:56] postprocess started ...
[15:37:56] postprocess finished in 25 ms
[15:37:56] lint started ...
[15:37:56] build prod finished in 110.64 s
> cordova run android --device
Android Studio project detected
(node:64964) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'find' of undefined
at Object.resolveParent (C:\Users\Simon K\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-common\src\util\xml-helpers.js:207:26)
at C:\Users\Simon K\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-common\src\ConfigChanges\ConfigChanges.js:345:53
at Array.forEach (<anonymous>)
at is_conflicting (C:\Users\Simon K\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-common\src\ConfigChanges\ConfigChanges.js:337:17)
at PlatformMunger.add_config_changes (C:\Users\Simon K\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-common\src\ConfigChanges\ConfigChanges.js:188:33)
at C:\Users\Simon K\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\src\cordova\prepare.js:130:32
at _fulfilled (C:\xampp\htdocs\project x\anonymous-social\platforms\android\cordova\node_modules\q\q.js:854:54)
at self.promiseDispatch.done (C:\xampp\htdocs\project x\anonymous-social\platforms\android\cordova\node_modules\q\q.js:883:30)
at Promise.promise.promiseDispatch (C:\xampp\htdocs\project x\anonymous-social\platforms\android\cordova\node_modules\q\q.js:816:13)
at C:\xampp\htdocs\project x\anonymous-social\platforms\android\cordova\node_modules\q\q.js:624:44
(node:64964) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:64964) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
我不确定为什么会这样。我尝试删除我的 node_modules
文件夹,然后执行 npm install
,但这并没有解决问题。我认为这可能是 android 问题?因为我仍然能够在 iOS
...
有什么想法吗?谢谢!!
设法(暂时?)通过删除 android
并重新安装来解决此问题...
cordova platform remove android
cordova platform add android
希望这对以后的人有所帮助。
您可以编辑文件
cordova\node_modules\cordova-common\src\util\xml-helpers.js:207:26
并添加
if(doc!==null) //add this line
parent = doc.find(selector);
它还有助于编译和安装 android 应用程序
我正在使用 Angular/Firebase 在 Ionic 中构建一个应用程序。
我想在我的 android 设备上测试该应用程序,该设备之前运行良好。但是,最近我无法 运行 它,因为出现错误。
$ ionic cordova run android --device --prod
然后导致错误:
Running app-scripts build: --prod --platform android --target cordova
[15:36:05] build prod started ...
[15:36:05] clean started ...
[15:36:05] clean finished in 6 ms
[15:36:05] copy started ...
[15:36:06] deeplinks started ...
[15:36:06] deeplinks finished in 270 ms
[15:36:06] ngc started ...
[15:36:19] ngc finished in 12.61 s
[15:36:19] preprocess started ...
[15:36:19] preprocess finished in 1 ms
[15:36:19] webpack started ...
[15:36:19] copy finished in 13.84 s
[15:37:27] webpack finished in 68.39 s
[15:37:27] uglify started ...
[15:37:27] sass started ...
Without `from` option PostCSS could generate wrong source map and will not find Browserslist config. Set it to CSS file path or to `undefined` to prevent this warning.
[15:37:29] sass finished in 1.66 s
[15:37:29] cleancss started ...
[15:37:31] cleancss finished in 2.77 s
[15:37:56] uglify finished in 28.99 s
[15:37:56] postprocess started ...
[15:37:56] postprocess finished in 25 ms
[15:37:56] lint started ...
[15:37:56] build prod finished in 110.64 s
> cordova run android --device
Android Studio project detected
(node:64964) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'find' of undefined
at Object.resolveParent (C:\Users\Simon K\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-common\src\util\xml-helpers.js:207:26)
at C:\Users\Simon K\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-common\src\ConfigChanges\ConfigChanges.js:345:53
at Array.forEach (<anonymous>)
at is_conflicting (C:\Users\Simon K\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-common\src\ConfigChanges\ConfigChanges.js:337:17)
at PlatformMunger.add_config_changes (C:\Users\Simon K\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-common\src\ConfigChanges\ConfigChanges.js:188:33)
at C:\Users\Simon K\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\src\cordova\prepare.js:130:32
at _fulfilled (C:\xampp\htdocs\project x\anonymous-social\platforms\android\cordova\node_modules\q\q.js:854:54)
at self.promiseDispatch.done (C:\xampp\htdocs\project x\anonymous-social\platforms\android\cordova\node_modules\q\q.js:883:30)
at Promise.promise.promiseDispatch (C:\xampp\htdocs\project x\anonymous-social\platforms\android\cordova\node_modules\q\q.js:816:13)
at C:\xampp\htdocs\project x\anonymous-social\platforms\android\cordova\node_modules\q\q.js:624:44
(node:64964) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:64964) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
我不确定为什么会这样。我尝试删除我的 node_modules
文件夹,然后执行 npm install
,但这并没有解决问题。我认为这可能是 android 问题?因为我仍然能够在 iOS
...
有什么想法吗?谢谢!!
设法(暂时?)通过删除 android
并重新安装来解决此问题...
cordova platform remove android
cordova platform add android
希望这对以后的人有所帮助。
您可以编辑文件
cordova\node_modules\cordova-common\src\util\xml-helpers.js:207:26
并添加
if(doc!==null) //add this line
parent = doc.find(selector);
它还有助于编译和安装 android 应用程序