【发布时间】:2021-09-28 11:32:38
【问题描述】:
【问题讨论】:
-
替代方案是 npm start 但我不明白为什么会这样。
-
我终于找到了一个完整的解决方案。帖子已编辑。
标签: visual-studio-code angular11
【问题讨论】:
标签: visual-studio-code angular11
我在 Visual Studio Code 中执行 Docker 命令时遇到了类似的问题。我还有一个窗口询问“你想如何打开这个文件?”。我认为问题不在于 Visual Studio Code,而在于 Visual Studio Code 使用的 PowerShell。
我是这样解决的:
对于 ng 应该是一样的。
【讨论】:
Petr Freiberg 的回答帮助我找到了我认为更好的解决方案。我们应该更新我们的 PATH 变量,以便首先找到“正确”的命令,而不是删除对系统可能实际上很重要或可能不重要的文件。
在我的情况下,我的 npm 路径按以下顺序排列:
C:\Users\Me\AppData\Roaming\npm\node_modules\@angular\cli\binC:\Users\Me\AppData\Roaming\npm我刚刚切换了顺序,以便 C:\Users\Me\AppData\Roaming\npm 排在第一位。
问题是终端正在寻找第一个“命令匹配”,它可能只是一个文件,这就是为什么它会询问您要在哪里打开它。
我确实按照 Petr 的建议运行了命令 Run Get-Command -All ng | ForEach-Object Path,这引发了我在此处描述的订单问题。
【讨论】:
我遇到了同样的问题,在尝试运行 ng -v 或 ng --version 时,它会弹出一个打开选项编辑器,它会提供以下 ng.js 文本...
#!/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] % 2 === 1 && version[0] > 14) {
// Allow new odd numbered releases with a warning (currently v15+)
console.warn(
'Node.js version ' +
process.version +
' detected.\n' +
'Odd numbered Node.js versions will not enter LTS status and should not be used for production.' +
' For more information, please see https://nodejs.org/en/about/releases/.',
);
require('../lib/init');
} else if (
version[0] < 12 ||
version[0] === 13 ||
(version[0] === 12 && version[1] < 14) ||
(version[0] === 14 && version[1] < 15)
) {
// Error and exit if less than 12.14 or 13.x or less than 14.15
console.error(
'Node.js version ' +
process.version +
' detected.\n' +
'The Angular CLI requires a minimum Node.js version of either v12.14 or v14.15.\n\n' +
'Please update your Node.js version or visit https://nodejs.org/ for additional instructions.\n',
);
process.exitCode = 3;
} else {
require('../lib/init');
}
what is the error here, i tried uninstall clear cache and install but still same error....
【讨论】: