gpt4 book ai didi

Dart 导入包不起作用

转载 作者:行者123 更新时间:2023-12-03 02:44:05 25 4
gpt4 key购买 nike

现在在 Dart 中导入包时遇到问题,该项目昨天还在运行,但今天停止了,我不知道为什么,整个周末代码都没有改变,我不记得运行任何更新。任何带有“package:” url 的内容都存在问题。例如,这两个在我的项目中都被破坏了:

import 'package:args/args.dart';
import 'package:crypto/crypto.dart';

这些错误消息是:
Unhandled exception:
Uncaught Error: FileSystemException: Cannot open file, path = 'D:\Dart\server\bin\packages\args\args.dart' (OS Error: The system cannot find the file specified. , errno = 2)
Stack Trace:
#0 _File.open.<anonymous closure> (dart:io/file_impl.dart:349)
#1 _RootZone.runUnary (dart:async/zone.dart:1151)
#2 _Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:496)
#3 _Future._propagateToListeners (dart:async/future_impl.dart:579)
#4 _Future._completeWithValue (dart:async/future_impl.dart:339)
#5 _Future._asyncComplete.<anonymous closure> (dart:async/future_impl.dart:401)
#6 _asyncRunCallbackLoop (dart:async/schedule_microtask.dart:41)
#7 _asyncRunCallback (dart:async/schedule_microtask.dart:48)
#8 _runPendingImmediateCallback (dart:isolate-patch/isolate_patch.dart:84)
#9 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:131)

#0 _rootHandleUncaughtError.<anonymous closure> (dart:async/zone.dart:883)
#1 _asyncRunCallbackLoop (dart:async/schedule_microtask.dart:41)
#2 _asyncRunCallback (dart:async/schedule_microtask.dart:48)
#3 _runPendingImmediateCallback (dart:isolate-patch/isolate_patch.dart:84)
#4 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:131)

这些在我的 pubspec.yaml 中:

name: server
description: A Server
dependencies:
args: ">=0.12.1 <0.13.0"
crypto: ">=0.9.0 <0.10.0"
io: ">=0.1.0-git <0.2.0"

并且 pub get(和 pub upgrade)运行成功:
"D:\Program Files\dart\dart-sdk\bin\pub.bat" upgrade
Resolving dependencies...
args 0.12.1
collection 1.1.0
crypto 0.9.0
io 0.1.0-git
No dependencies changed.
Process finished with exit code 0

创建一个全新的项目并复制代码会产生同样的问题。我还尝试删除所有项目包目录和 pubspec.lock 文件并重新运行 pub get,虽然它成功检索了包,但仍然没有运气。

尽管包目录似乎是空的,但当您在 ​​Windows 文件系统中向下钻取时,只有一堆快捷方式最终出现在空目录中?

用完想法,这对开发客户端应用程序至关重要。任何想法将不胜感激!

最佳答案

我很确定你可以用 pub cache repair 解决这个问题(在命令行上执行)或删除 pub 缓存目录。

关于Dart 导入包不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26842778/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com