angularjs Angular ng命令不工作,无任何错误

xuo3flqw  于 2023-02-03  发布在  Angular
关注(0)|答案(1)|浏览(376)

Windows 11 Pro 22H2,节点v19.5.0,我无法获得Angular 版本
运行命令npm install -g @angular/cli将返回以下内容:

npm WARN deprecated @npmcli/move-file@2.0.1: This functionality has been moved to @npmcli/fs

changed 224 packages in 28s

26 packages are looking for funding
  run `npm fund` for details

然后运行npm fund只返回我当前所在的文件夹名称。
尝试运行ng newng --version立即在终端中返回,没有任何结果,并且没有任何操作。
如果我进入正在处理的活动项目并尝试运行ng g c test
它将打开一个ng.js文件,其中包含以下内容:

#!/usr/bin/env node
/**
 * @license
 * Copyright Google LLC All Rights Reserved.
 *
 * Use of this source code is governed by an MIT-style license that can be
 * found in the LICENSE file at https://angular.io/license
 */

/* eslint-disable no-console */
/* eslint-disable import/no-unassigned-import */
'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';
}

const rawCommandName = process.argv[2];

if (rawCommandName === '--get-yargs-completions' || rawCommandName === 'completion') {
  // Skip Node.js supported checks when running ng completion.
  // A warning at this stage could cause a broken source action (`source <(ng completion script)`) when in the shell init script.
  require('./bootstrap');

  return;
}

// 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.
var version = process.versions.node.split('.').map((part) => Number(part));
if (version[0] % 2 === 1) {
  // Allow new odd numbered releases with a warning (currently v17+)
  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('./bootstrap');
} else if (
  version[0] < 14 ||
  (version[0] === 14 && version[1] < 20) ||
  (version[0] === 16 && version[1] < 13) ||
  (version[0] === 18 && version[1] < 10)
) {
  // Error and exit if less than 14.20, 16.13 or 18.10
  console.error(
    'Node.js version ' +
      process.version +
      ' detected.\n' +
      'The Angular CLI requires a minimum Node.js version of either v14.20, v16.13 or v18.10.\n\n' +
      'Please update your Node.js version or visit https://nodejs.org/ for additional instructions.\n',
  );

  process.exitCode = 3;
} else {
  require('./bootstrap');
}

我是一个很新的Angular ,不知道是什么原因造成的,对我来说,它看起来像是想要一个最小的节点版本,但我的节点版本应该工作,因为它是最新的版本之一。
感谢您的帮助。

0pizxfdo

0pizxfdo1#

ng.js文件中的错误消息指示您的Node.js版本与您尝试使用的Angular CLI版本不兼容。Angular CLI要求Node.js版本至少为v14.20、v16.13或v18.10。它与您的Node.js版本类似(v19.5.0)不兼容。要解决此问题,您可以更新Node.js版本,或使用与当前Node.js版本兼容的较旧版本的Angular CLI。

相关问题