Dart导入包无效

时间:2014-11-10 11:28:53

标签: dart dart-editor dart-pub

现在有关于在Dart中导入软件包的问题,​​该项目昨天正在运行,但今天已停止,我不知道为什么,代码周末没有改变,我不记得运行任何更新。使用"包存在任何问题:"网址。例如,在我的项目中,这两个都被打破了:

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再次,虽然它成功检索了包,但没有运气。

包目录看起来似乎是空的,只是当你在windows文件系统中向下钻取时,一堆快捷方式最终会出现在空目录中?

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

1 个答案:

答案 0 :(得分:5)

我很确定您可以使用pub cache repair(在命令行上执行)或者删除pub缓存目录来解决此问题。