Cordova构建错误:在严格模式下使用const

时间:2019-02-21 07:48:53

标签: node.js cordova npm

我在VS 2015中创建了一个新的Cordova项目。当我尝试运行代码时,我的构建输出中出现以下错误:

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 ==========

我的节点版本是v11.10.0,我的npm版本是6.7.0。

1 个答案:

答案 0 :(得分:1)

我遇到了类似的问题,我采取了以下步骤:

转到以下目录:

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

在package.json文件中,您将找到请求。将请求从您的版本更改为'2.81.0'