Unable to find reference source: packages

I have a pubspec.yaml

name: Dart Pages description: The Dart platform. dependencies: web_components: any mongo_dart: any 

then I launched Tools> Pub Install, the operation completes successfully.

When starting the application, I get the following error:

  dart --enable-checked-mode web\page.dart Unable to open file: C:/Users/Samer/Documents/GitHub/dart/web/packages/mongo_dart/mongo_dart.dart'file:///C:/Users/Samer/Documents/GitHub/dart/web/page.dart': Error: line 1 pos 1: library handler failed #import("package:mongo_dart/mongo_dart.dart"); 

I am using Windows 7 64bit and the latest Dart editor version 0.2.1_r14167

Problems arise not only with mongo_dart, but also with all other libraries, the editor is looking for the wrong package path in / dart / web / packages, while I see a folder in the / dart / packages folder.

Thank you for your help and time.

+4
source share
5 answers

Have you pub install since the creation of the "web" directory? If not, try this. You need to have the "packages" directory in the directory that contains your Dart entry point so that the import of "package:" is correctly resolved.

The pub will create these directories for you, but it needs to know to do this. If you add a new directory to your package, you will want to run pub install again so that it adds the "packages" directory to it.

+1
source

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

After a lot of unrest, I finally discovered, mainly through trial and error, that the problem was caused by TeamCity clearing the folder before creating the solution.

I can’t find any reasonable documentation on how pub works, and I don’t know why this only works for the first time, but my trial version and error found that doing pub cache repair for each build before pub get and finally pub build is repeatable, and my TeamCity project will now work successfully every time.

+1
source

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

Original announcement:

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

Amended declaration:

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

You can also try this (this worked with me):

  import 'packages/mongo_dart/mongo_dart.dart'; 
0
source

You may need to add an additional library into which you import the mongo_dart.dart file, and then import the library into your main body. This is a strange solution that I know, but it worked for me when I tried to get Google Maps to work inside Dart.

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

0
source

I had similar problems trying to import unittest. I am running Eclipse 4.2 on Windows 7 64 bit with the dart editor plugin.

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

The loan belongs to Samer Ali in the darlang google group for this, see here .

0
source

Source: https://habr.com/ru/post/1443254/


All Articles