Cannot find referenced source: packages

前端 未结 5 611
我寻月下人不归
我寻月下人不归 2021-01-13 14:10

I have this pubspec.yaml

    name: Dart Pages
    description: The Dart platform.
    dependencies:
      web_compon         


        
相关标签:
5条回答
  • 2021-01-13 14:36

    I had a similar problem with TeamCity. On my development machine I can do pub get and pub build over and over and it works just great, but this only worked the very first time I built the solution using TeamCity.

    After a lot of messing around I finally discovered, mostly by trial and error, that the problem was caused by TeamCity cleaning the folder before building the solution.

    I can't find any reasonable documentation for how pub works, and I don't know why this only works the very first time, but my trial and error discovered that executing pub cache repair on every build before pub get and finally pub build works repeatably, and my TeamCity project now builds successfully every time.

    0 讨论(0)
  • 2021-01-13 14:39

    I was having similar problems trying to import unittest. I'm running Eclipse 4.2 in windows 7 64 bit with the dart editor plugin.

    Deleting the 'pub' folder under c:\USERS\<user>\AppData\Roaming\ worked for me.

    The credit goes to Samer Ali on the darlang google group for this one, see here.

    0 讨论(0)
  • 2021-01-13 14:47

    Have you run pub install since you created the "web" directory? If not, try that. You need to have a "packages" directory inside the directory that contains your Dart entrypoint in order for "package:" imports to resolve correctly.

    Pub will create those directories for you, but it needs to know to do that. If you add a new directory to your package, you'll want to run pub install again so it add a "packages" directory to it.

    0 讨论(0)
  • 2021-01-13 14:50

    You might need to add an additional library where you import mongo_dart.dart and then import the library in your main. It's a weird solution I know but it worked for me when I was trying to get Google Maps running inside Dart.

    More here: https://groups.google.com/a/dartlang.org/d/msg/misc/ORXJmmmH3fA/WIKyBik1e7sJ

    0 讨论(0)
  • 2021-01-13 14:51

    I had something similar here, with the js-interop package. I changed the ':' to '/' and it worked.

    Original declaration:

        import("package:mongo_dart/mongo_dart.dart");
    

    Modified declaration:

        #import("package/mongo_dart/mongo_dart.dart");
    

    You could also try this (It has worked to me):

        import 'packages/mongo_dart/mongo_dart.dart';
    
    0 讨论(0)
提交回复
热议问题