“路径”参数必须是字符串类型。接收到的类型未定义 - Ionic 4 - 仅限 Windows
Posted
技术标签:
【中文标题】“路径”参数必须是字符串类型。接收到的类型未定义 - Ionic 4 - 仅限 Windows【英文标题】:The "path" argument must be of type string. Received type undefined - Ionic 4 - Windows only 【发布时间】:2020-04-22 21:16:17 【问题描述】:我遇到了一个错误,我不知道它是如何发生的,但它阻止我在 PC 上开发...我可以在 Mac 上构建我的应用程序,但是当我在 Windows 机器上尝试时它失败了。
cordova build android --stacktrace
未定义的配置文件请求的更改未在 平台\安卓\未定义,忽略配置文件未定义请求未找到的更改 平台\android\未定义,忽略
“路径”参数必须是字符串类型。接收类型未定义
TypeError [ERR_INVALID_ARG_TYPE]:“路径”参数必须是类型 细绳。接收类型未定义
在 validateString (internal/validators.js:112:11)
甚至在从 GIT 克隆的干净 Windows 机器上也是如此。
$ 离子信息
离子:
Ionic CLI:5.4.13 (\AppData\Roaming\npm\node_modules\ionic) 离子框架:@ionic/angular 4.11.7 @angular-devkit/build-angular:0.803.21 @angular-devkit/原理图:8.1.3 @角/cli:8.3.20 @ionic/angular-toolkit:2.0.0
科尔多瓦:
Cordova CLI:9.0.0 (cordova-lib@9.0.1) Cordova 平台:安卓 8.1.0 Cordova 插件:cordova-plugin-ionic-keyboard 2.2.0、cordova-plugin-ionic-webview 4.1.3(和其他 12 个插件)
实用程序:
cordova 分辨率:0.8.1 本机运行:0.3.0
系统:
NodeJS : v12.14.0 (C:\Program Files\nodejs\node.exe) npm:6.13.4 操作系统:Windows 10
"name": "xyz1",
"version": "0.0.7",
"author": "Keni Barwick",
"homepage": "https://barwick.net/",
"scripts":
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
,
"private": true,
"dependencies":
"@angular/common": "~8.1.2",
"@angular/compiler": "~8.1.2",
"@angular/core": "~8.1.2",
"@angular/fire": "^5.2.1",
"@angular/forms": "~8.1.2",
"@angular/http": "^7.2.15",
"@angular/platform-browser": "~8.1.2",
"@angular/platform-browser-dynamic": "~8.1.2",
"@angular/router": "~8.1.2",
"@ionic-native/app-version": "^5.18.0",
"@ionic-native/core": "^5.18.0",
"@ionic-native/google-analytics": "^5.18.0",
"@ionic-native/health": "^5.18.0",
"@ionic-native/image-picker": "^5.18.0",
"@ionic-native/ionic-webview": "^5.18.0",
"@ionic-native/onesignal": "^5.18.0",
"@ionic-native/splash-screen": "^5.18.0",
"@ionic-native/status-bar": "^5.18.0",
"@ionic/angular": "^4.11.7",
"cordova-android": "^8.1.0",
"cordova-plugin-androidx": "^1.0.2",
"cordova-plugin-androidx-adapter": "^1.1.0",
"cordova-plugin-app-version": "^0.1.9",
"cordova-plugin-exitapp2": "^1.0.4",
"cordova-plugin-firebasex": "^7.0.1",
"cordova-plugin-google-analytics": "1.6.0",
"cordova-plugin-health": "^1.1.3",
"cordova-plugin-telerik-imagepicker": "^2.3.3",
"cordova-res": "^0.8.1",
"core-js": "^2.6.11",
"firebase": "^6.5.0",
"html-webpack-plugin": "^3.2.0",
"kr.co.joycorp.cordova.exitapp": "^1.0.2",
"ngx-pipes": "^2.6.0",
"npm": "^6.13.4",
"onesignal-cordova-plugin": "^2.8.1",
"rxjs": "^6.5.4",
"tslib": "^1.9.0",
"zone.js": "~0.9.1"
,
"devDependencies":
"@angular-devkit/architect": "~0.801.2",
"@angular-devkit/build-angular": "^0.803.21",
"@angular-devkit/core": "~8.1.2",
"@angular-devkit/schematics": "~8.1.2",
"@angular/cli": "8.3.20",
"@angular/compiler": "~8.1.2",
"@angular/compiler-cli": "~8.1.2",
"@angular/language-service": "~8.1.2",
"@ionic/angular-toolkit": "~2.0.0",
"@ionic/lab": "2.0.10",
"@types/jasmine": "~3.3.8",
"@types/jasminewd2": "~2.0.3",
"@types/node": "~8.9.4",
"codelyzer": "^5.2.1",
"cordova-plugin-device": "^2.0.2",
"cordova-plugin-ionic-keyboard": "^2.2.0",
"cordova-plugin-ionic-webview": "^4.1.1",
"cordova-plugin-splashscreen": "^5.0.2",
"cordova-plugin-statusbar": "^2.4.2",
"cordova-plugin-whitelist": "^1.3.3",
"jasmine-core": "~3.4.0",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~4.1.0",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "~2.0.1",
"karma-jasmine": "~2.0.1",
"karma-jasmine-html-reporter": "^1.5.1",
"protractor": "~5.4.0",
"ts-node": "~7.0.0",
"tslint": "~5.15.0",
"typescript": "~3.4.3"
,
"description": "An Ionic project",
"cordova":
"plugins":
"cordova-plugin-telerik-imagepicker": ,
"cordova-plugin-health":
"HEALTH_READ_PERMISSION": "App needs read access",
"HEALTH_WRITE_PERMISSION": "App needs write access",
"GMS_VERSION": "16.0.1"
,
"cordova-plugin-whitelist": ,
"cordova-plugin-statusbar": ,
"cordova-plugin-device": ,
"cordova-plugin-splashscreen": ,
"cordova-plugin-ionic-webview":
"ANDROID_SUPPORT_ANNOTATIONS_VERSION": "27.+"
,
"cordova-plugin-ionic-keyboard": ,
"kr.co.joycorp.cordova.exitapp": ,
"cordova-plugin-app-version": ,
"cordova-plugin-google-analytics": ,
"cordova-plugin-firebasex": ,
"cordova-plugin-androidx-adapter": ,
"onesignal-cordova-plugin":
,
"platforms": [
"android"
],
"browserslist": []
我已经更新了所有在 npm outdated 中显示为红色的插件,检查了很多 Stacks 的答案但无济于事......
【问题讨论】:
是否有更长的堆栈跟踪错误?您将不得不深入了解哪条路径是错误的以及它来自哪里。在我看来,应该将platforms\android\xxx
设置为指向某个配置文件的任何东西都在搞砸,所以它找不到您的配置文件,也许这就是路径错误的原因。
在这篇文章中挖掘它可能会对您有所帮助:github.com/ionic-team/ionic-cli/issues/1082
感谢两位的帮助
【参考方案1】:
我一创建帖子就知道我会找到答案,哈哈
所以问题出在 config.xml 中,特别是以下问题;
<config-file parent="NSHealthShareUsageDescription" platform="ios">
<string>App needs read access</string>
</config-file>
<config-file parent="NSHealthUpdateUsageDescription" platform="ios">
<string>App needs write access</string>
</config-file>
我删除了上述内容,我试图理解为什么我会收到以下警告;
config file undefined requested for changes not found at platforms\android\undefined, ignoring
一旦我删除它,我就可以通过路径错误...奇怪吗?
【讨论】:
【参考方案2】:就我而言,改变:
<config-file
到
<gap:config-file
解决了这个问题。
编辑: 有另一个应用程序,另一个案例。 我必须在配置文件中添加“目标”属性。 示例:
<config-file target="AndroidManifest.xml" parent="/manifest">
另外,如果你有一个为PhoneGapBuild准备的项目,现在你需要自己编译它,记得在“平台”下设置你的配置来区分平台设置。 示例:
<plaform name="android">
<config-file target="AndroidManifest.xml" parent="/manifest">
【讨论】:
以上是关于“路径”参数必须是字符串类型。接收到的类型未定义 - Ionic 4 - 仅限 Windows的主要内容,如果未能解决你的问题,请参考以下文章
图片上传错误:TypeError [ERR_INVALID_ARG_TYPE]:“路径”参数必须是字符串类型。接收类型未定义
ModuleBuildError:模块构建失败:TypeError [ERR_INVALID_ARG_TYPE]:“路径”参数必须是字符串类型。接收类型未定义
fs.FileRead -> TypeError [ERR_INVALID_ARG_TYPE]:“路径”参数必须是字符串、缓冲区或 URL 类型之一。接收类型未定义
如何解决:“路径”参数必须是字符串类型。运行'vue add vuetify'时收到类型未定义'