node.js - Cordova 构建错误 : Use of const in strict mode

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

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

最佳答案

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

转到以下目录:

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'

关于node.js - Cordova 构建错误 : Use of const in strict mode,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54801802/

相关文章:

android - Apache Cordova 在 div 中加载外部 URL 或网站

javascript - Phonegap/Cordova CSS 无法正常工作

Node.js 一次锁定一个用户

javascript - Sails.js 分离项目中的 View 和 Assets

javascript - 如何在 NodeJS 中将数组分成相等的部分

javascript - onkeypress 无法以表单形式运行

node.js - npm install 与 edit package.json 和 npm update

javascript - npm 安装错误 "ETXTBSY: text file is busy"

node.js - JXCore打包,NPM错误

node.js - Node : how can I wait for pipe and createWriteStream to finish before executing next lines?