无法安装获取CLI

问题描述 投票:0回答:1

我尝试在Windows 10中通过CMD安装get CLI,并且可以顺利创建项目,我的flutter和dart版本是最新的Flutter版本3.16.7和Dart版本3.2.4,之后的问题是当它flutter pub get时,我收到这样的错误:

Running `flutter pub get` …

$ flutter pub get
Resolving dependencies...
  flutter_lints 2.0.3 (3.0.1 available)
  lints 2.1.1 (3.0.0 available)
  matcher 0.12.16 (0.12.16+1 available)
  material_color_utilities 0.5.0 (0.8.0 available)
  meta 1.10.0 (1.11.0 available)
  path 1.8.3 (1.9.0 available)
  test_api 0.6.1 (0.7.0 available)
  web 0.3.0 (0.4.2 available)
Got dependencies!
8 packages have newer versions incompatible with dependency constraints.
Try `flutter pub outdated` for more information.
$ dart migrate --apply-changes --skip-import-check
Could not find a command named "migrate".

Usage: dart <command|dart-file> [arguments]

Global options:
-v, --verbose               Show additional command output.
    --version               Print the Dart SDK version.
    --enable-analytics      Enable analytics.
    --disable-analytics     Disable analytics.
    --suppress-analytics    Disallow analytics for this `dart *` run without changing the analytics configuration.
-h, --help                  Print this usage information.

Available commands:
  analyze    Analyze Dart code in a directory.
  compile    Compile Dart to various formats.
  create     Create a new Dart project.
  devtools   Open DevTools (optionally connecting to an existing application).
  doc        Generate API documentation for Dart projects.
  fix        Apply automated fixes to Dart source code.
  format     Idiomatically format Dart source code.
  info       Show diagnostic information about the installed tooling.
  pub        Work with packages.
  run        Run a Dart program.
  test       Run tests for a project.

Run "dart help <command>" for more information about a command.
See https://dart.dev/tools/dart-tool for detailed documentation.
✖  + error_unexpected ShellException(dart migrate --apply-changes --skip-import-check, exitCode 64, workingDirectory: C:\Users\USER\train_gunawan)


Time: 12049 Milliseconds

C:\用户\用户>

完整的CMD命令:

C:\Users\USER>get create project train_gunawan

  1) Flutter Project
  2) Get Server
Select which type of project you want to create ? [1]
What is your company's domain?  Example: com.yourcompany  com.traingunawan

  1) Swift
  2) Objective-C
what language do you want to use on ios? [1]

  1) Kotlin
  2) Java
what language do you want to use on android? [1]

  1) Yes!
  2) No
Do you want to use null safe? [1]

  1) yes
  2) no
do you want to use some linter? [1]

Running `flutter create C:\Users\USER\train_gunawan` …

$ flutter create --no-pub -i swift -a kotlin --org com.traingunawan C:\Users\USER\train_gunawan
Recreating project ....
Wrote 3 files.

All done!
You can find general documentation for Flutter at: https://docs.flutter.dev/
Detailed API documentation is available at: https://api.flutter.dev/
If you prefer video documentation, consider: https://www.youtube.com/c/flutterdev

In order to run your application, type:

  $ cd .
  $ flutter run

Your application code is in .\lib\main.dart.


Running `flutter pub get` …

$ flutter pub get
Resolving dependencies...
  flutter_lints 2.0.3 (3.0.1 available)
  lints 2.1.1 (3.0.0 available)
  matcher 0.12.16 (0.12.16+1 available)
  material_color_utilities 0.5.0 (0.8.0 available)
  meta 1.10.0 (1.11.0 available)
  path 1.8.3 (1.9.0 available)
  test_api 0.6.1 (0.7.0 available)
  web 0.3.0 (0.4.2 available)
Got dependencies!
8 packages have newer versions incompatible with dependency constraints.
Try `flutter pub outdated` for more information.
$ dart migrate --apply-changes --skip-import-check
Could not find a command named "migrate".

Usage: dart <command|dart-file> [arguments]

Global options:
-v, --verbose               Show additional command output.
    --version               Print the Dart SDK version.
    --enable-analytics      Enable analytics.
    --disable-analytics     Disable analytics.
    --suppress-analytics    Disallow analytics for this `dart *` run without changing the analytics configuration.
-h, --help                  Print this usage information.

Available commands:
  analyze    Analyze Dart code in a directory.
  compile    Compile Dart to various formats.
  create     Create a new Dart project.
  devtools   Open DevTools (optionally connecting to an existing application).
  doc        Generate API documentation for Dart projects.
  fix        Apply automated fixes to Dart source code.
  format     Idiomatically format Dart source code.
  info       Show diagnostic information about the installed tooling.
  pub        Work with packages.
  run        Run a Dart program.
  test       Run tests for a project.

Run "dart help <command>" for more information about a command.
See https://dart.dev/tools/dart-tool for detailed documentation.
✖  + error_unexpected ShellException(dart migrate --apply-changes --skip-import-check, exitCode 64, workingDirectory: C:\Users\USER\train_gunawan)


Time: 12049 Milliseconds


C:\Users\USER>

请我尽快需要您的帮助,至少还剩 1 天。谢谢你

flutter mobile flutter-dependencies get-cli
1个回答
0
投票

错误信息“无法找到名为‘migrate’的命令”表示未找到 dart migrate 命令。这可能是由多种原因引起的,其中一种可能是 Dart SDK 未安装或配置不正确。

您可以尝试以下步骤:

  1. 确保已安装 Dart SDK: 确保您的系统上安装了 Dart SDK。您可以从Dart官方网站下载:Dart SDK。

  2. 确保 Dart SDK 在路径中: 下载并安装 Dart SDK 后,请确保 Dart 安装目录位于系统的 PATH 中。这允许您从终端或 cmd 中的任何位置访问 Dart 命令。

直接运行 dart migrate 命令: 尝试直接从项目目录运行 dart migrate 命令而不使用引号:

cd C:\Users\USER\train_gunawan
dart migrate --apply-changes --skip-import-check

运行此命令之前,请确保您位于项目目录中。

更新 Flutter 和 Dart: 确保系统上的 Flutter 和 Dart 已更新到最新版本。您可以使用以下命令来更新 Flutter 和 Dart:

flutter upgrade

flutter pub global activate dart

flutter pub global activate migration

运行这些命令后,尝试再次运行 dart migrate 命令。

如果尝试上述步骤后仍然遇到问题,请告诉我

© www.soinside.com 2019 - 2024. All rights reserved.