Cordova-build error: Use of const in strict mode

耗尽温柔 提交于 2021-02-10 04:57:47

问题


I've created a new Cordova project in VS 2015. When I'm try to run the code I'm getting the following errors in my build output:

1>------ Build started: Project: TestProject, Configuration: Debug Android ------
1>  ------ Ensuring correct global installation of package from source package directory: C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO 14.0\COMMON7\IDE\EXTENSIONS\APACHECORDOVATOOLS\packages\vs-tac
1>  ------ Name from source package.json: vs-tac
1>  ------ Version from source package.json: 1.0.42
1>  ------ Package already installed globally at correct version.
1>  ------ Cordova tools 6.1.1 already installed.
1>  ------ Build Settings:
1>  ------ Build Settings:
1>  ------    platformConfigurationBldDir: C:\Users\safan.allauddin\documents\visual studio 2015\Projects\TestProject\TestProject\bld\Android\Debug
1>  ------    platformConfigurationBinDir: C:\Users\safan.allauddin\documents\visual studio 2015\Projects\TestProject\TestProject\bin\Android\Debug
1>  ------    buildCommand: prepare
1>  ------    platform: Android
1>  ------    cordovaPlatform: android
1>  ------    configuration: Debug
1>  ------    cordovaConfiguration: Debug
1>  ------    projectName: TestProject
1>  ------    projectSourceDir: C:\Users\safan.allauddin\documents\visual studio 2015\Projects\TestProject\TestProject
1>  ------    npmInstallDir: C:\Users\safan.allauddin\AppData\Roaming\npm
1>  ------    language: en-US
1>  ------ Adding platform: android
1>MSBUILD : cordova-build error : SyntaxError: C:\Users\safan.allauddin\AppData\Roaming\npm\node_modules\vs-tac\node_modules\cordova\6.1.1\node_modules\cordova\node_modules\cordova-lib\node_modules\request\node_modules\tough-cookie\node_modules\ip-regex\index.js:3
1>  SyntaxError C:\Users\safan.allauddin\AppData\Roaming\npm\node_modules\vs-tac\node_modules\cordova\6.1.1\node_modules\cordova\node_modules\cordova-lib\node_modules\request\node_modules\tough-cookie\node_modules\ip-regex\index.js:3
1>MSBUILD : cordova-build error : const v4 = '(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])(?:\\.(?:25[0-
1>  const v4 = '(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])(?:\\.(?:25[0-
1>MSBUILD : cordova-build error : ^^^^^
1>  ^^^^^
1>MSBUILD : cordova-build error : Use of const in strict mode.
1>  Use of const in strict mode.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
========== Deploy: 0 succeeded, 0 failed, 0 skipped ==========

My node version is v11.10.0 and my npm version is 6.7.0.


回答1:


I had a similar issue and I took the following steps:

Go to the following directory:

C:\Users\'USER'\AppData\Roaming\npm\node_modules\vs-tac\node_modules\cordova\'CORDOVA VERSION'\node_modules\cordova\node_modules\cordova-lib\package.json

In package.json file you'll find request. Change the request to '2.81.0' from your version.



来源:https://stackoverflow.com/questions/54801802/cordova-build-error-use-of-const-in-strict-mode

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!