"JavaScript Debug Configuration" debug launch for Dart project results in pub error "Directory "lib" is not allowed."
I have a Dart project that I am attempting to launch in Debug mode from Webstorm. To do so I have right clicked on my "index.html" and selected Debug. This automatically created a JavaScript Debug Configuration entry in the Configurations settings area. However, whenever I click Debug for this configuration (including the first time) the browser launches but the program does not run. The following error message is found in the "Pub Serve" tray panel:
/usr/lib/dart/bin/pub serve web --port=57607
Loading source assets...
Loading dart_to_js_script_rewriter transformers...
Serving plinypad web on http://localhost:57607
Build completed successfully
[web] GET Served 5 assets.
/usr/lib/dart/bin/pub serve lib --port=54722
[web] GET Served 14 assets.
Directory "lib" is not allowed.
Usage: pub serve [directories...]
-h, --help Print this usage information.
--mode Mode to run transformers in.
(defaults to "debug")
--all Use all default source directories.
-D, --define Defines an environment constant for dart2js.
--hostname The hostname to listen on.
(defaults to "localhost")
--port The base port to listen on.
(defaults to "8080")
--[no-]dart2js Compile Dart to JavaScript.
(defaults to on)
--[no-]force-poll Force the use of a polling filesystem watcher.
Run "pub help" to see global options.
See http://dartlang.org/tools/pub/cmd/pub-serve.html for detailed documentation.
Pub Serve terminated
I have other Dart projects on the same machine that appear to work fine, however, when they launch I see the following output with only one invocation of pub
/usr/lib/dart/bin/pub serve web --port=58172
Loading source assets...
Loading dart_to_js_script_rewriter transformers...
Serving vellum web on http://localhost:58172
Build completed successfully
[web] GET Served 5 assets.
[web] GET Served 272 assets.
请先登录再写评论。
I've discovered the issue come ups when I change my content root. If I start a new default project and run the default simple web app the program launches fine and only has
/usr/lib/dart/bin/pub serve web --port=38059
displayed in Pub Serve.
As soon as I change the content root to point to my existing application the problem begins to arise with both the line above and
/usr/lib/dart/bin/pub serve lib --port=54943
Most likely your project violates Pub Package Layout Conventions.
I guess you have some *.dart file in web folder that references another *.dart file from lib folder by relative path (this may be an import, export or part statement). This doesn't work in dart. Make sure that:
When you fix all of these, you should not see 'pub serve lib' any more.
This was the problem. Thanks.
Alexander,
What about files in the /packages folder referenced within /lib/main_app.dart of a sample Polymer Dart project as in:
@HtmlImport('main_app.html')
library proactive_healthcare.lib.main_app;
import 'dart:html';
import 'package:polymer_elements/paper_input.dart';
import 'package:polymer/polymer.dart';
import 'package:web_components/web_components.dart';
/// Uses [PaperInput]
@PolymerRegister('main-app')
class MainApp extends PolymerElement {
@property
String text;
/// Constructor used to create instance of MainApp.
MainApp.created() : super.created();
@reflectable
String reverseText(String text) {
return text.split('').reversed.join('');
}
}
Let me clarify the 2nd bullet:
References to other packages are allowed in any file.
Thanks for the clarification.