最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Can I use a Node library in a Dart server - Stack Overflow

programmeradmin0浏览0评论

Is it possible to import a Node module (NPM) into a Dart server?

From what I can see, JS interop only works with client-side Dart, is that right?

Can a Javascript library be included into a pubspec file and the content of that library used in the server via js interop?

Is there some other way of including JS in Dart server code?

Is it possible to import a Node module (NPM) into a Dart server?

From what I can see, JS interop only works with client-side Dart, is that right?

Can a Javascript library be included into a pubspec file and the content of that library used in the server via js interop?

Is there some other way of including JS in Dart server code?

Share Improve this question edited Jul 8, 2014 at 11:22 Rahul Sharma 3471 silver badge16 bronze badges asked Jul 8, 2014 at 11:18 kpgkpg 8,0087 gold badges36 silver badges74 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 2

If you want to run your Dart app on NodeJS, you need to use package:node_preamble. https://pub.dev/packages/node_preamble

A prominent package that does that is Sass. In fact, when you pile Sass to CSS, you are most likely using the Dart piler running on Node. Examining the repository will give you some hints how they go about it: Dart Sass

From what I can see, JS interop only works with client-side Dart, is that right?

Nope If you examine Dart Sass implementation, you will see interop declarations in it. You should be able to create Dart wrappers around JS functionality. Another example that does this is: Firestore for web

The interop uses package:js

edit: just realized how old the original question was :) Ohh well..

Of what I have heard you can build Dart to JS and run the result in Node.js. I guess here you can use Node modules too. Using a Node module when running as Dart is not possible I guess.

发布评论

评论列表(0)

  1. 暂无评论