node.js - Angular 在初始配置期间给出语法错误
问题描述
我正在尝试在 Windows 10 操作系统上创建 Angular 应用程序。以前当我尝试安装 Node.js 和 NPM 时,我得到“找不到未定义的“解决””。我通过将 Node.js 降级到 6.17 并将 NPM 降级到 3.10 来解决它。我现在可以下载 Angular CLI,但是当我使用“新”命令时,出现以下错误。
C:\Users\user_name\AppData\Roaming\npm\node_modules\@angular\cli\bin\ng:23
);
^
SyntaxError: Unexpected token )
at createScript (vm.js:56:10)
at Object.runInThisContext (vm.js:97:10)
at Module._compile (module.js:549:28)
at Object.Module._extensions..js (module.js:586:10)
at Module.load (module.js:494:32)
at tryModuleLoad (module.js:453:12)
at Function.Module._load (module.js:445:3)
at Module.runMain (module.js:611:10)
at run (bootstrap_node.js:394:7)
at startup (bootstrap_node.js:160:9)
当我打开文件位置时,我得到以下信息:
#!/usr/bin/env node
'use strict';
// Provide a title to the process in `ps`.
// Due to an obscure Mac bug, do not start this title with any symbol.
try {
process.title = 'ng ' + Array.from(process.argv).slice(2).join(' ');
} catch (_) {
// If an error happened above, use the most basic title.
process.title = 'ng';
}
// This node version check ensures that extremely old versions of node are not used.
// These may not support ES2015 features such as const/let/async/await/etc.
// These would then crash with a hard to diagnose error message.
// tslint:disable-next-line: no-var-keyword
var version = process.versions.node.split('.').map(part => Number(part));
if (version[0] < 10 || version[0] === 11 || (version[0] === 10 && version[1] < 13)) {
process.stderr.write(
'Node.js version ' + process.version + ' detected.\n' +
'The Angular CLI requires a minimum Node.js version of either v10.13 or v12.0.\n\n' +
'Please update your Node.js version or visit https://nodejs.org/ for additional instructions.\n',
);
process.exit(3);
}
require('../lib/init');
它抱怨 if 语句的括号。我试着去掉括号,它只会让情况变得更糟。解决这种情况的最佳方法是什么。以某种方式安装新版本的 Node 并解决“解决”错误或使用我手头的版本会更好吗?
解决方案
推荐阅读
- php - 如何使用 Youtube Data API 将某些电子邮件地址添加到允许列表以访问我的私人 youtube 视频?
- machine-learning - 在多类分类的情况下应该如何处理不平衡类
- python - 乘法和添加权重networkx图python
- c# - 以编程方式触发触觉时,Vive 控制器上发出奇怪的哔哔声(Unity3D / SteamVR 2.0)
- xamarin - 无法转换任务
布尔在 Xamarin 窗体 CrossConnectivity 插件? - hive - 如何解析地图
使用mapreduce从具有RCFile存储格式的HDFS? - excel - 将数字与随机字母和数字的文本字符串完全匹配
- python - 我无法在 django 2.1.4 中为应用程序进行迁移
- spring - HTTP 400 错误未在 Spring Boot 中登录,尽管 404 和其他错误
- github - IntelliJ,无法在 GitHub 上共享项目(权限被拒绝)