Dart2JS cannot find WebStorm import packages

I am using WebStorm 8 IDE to create a web darter application. I have the following directory structure:

root
   web
      main.dart
   lib
   packages
      browser
      intl
         intl.dart
   pubspec.lock
   pubspec.yaml

      

Q main.dart

I have the following import status:import "package:intl/intl.dart";

However, when I try to compile main.dart

to javascript, I get the following error:

dart2js
Error occurred:
/Path/To/Project/root/web/main.dart:2:8:
Error: Can't read 'package:intl/intl.dart' (Error reading '/Path/To/Project/root/web/packages/intl/intl.dart' (OS Error: No such file or directory, errno = 2)).
import "package:../packages/intl/intl.dart";
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error: Compilation failed.

      

So it seems that dart2js is looking at the current directory of the dart file to be converted for packages, which is not correct.

I tried to change my import statement to import "package:../packages/intl/intl.dart";

, but I got the same error.

Does anyone have any ideas?

UPDATE:

I can use pub build

to build my project and build main.dart.js

. Not sure what happens when I call the assembly, maybe there is something wrong with the WebStorm?

+3


source to share


2 answers


I don't see anything wrong. I think this is one of the cases where only

pub cache repair

      



may I help.

0


source


dart2js is not a recommended workflow and may be a bug in WebStorm 8. It has been completely removed from the context menu in the upcoming WebStorm 9. Use "pub build".



+1


source







All Articles