nerd icon indicating copy to clipboard operation
nerd copied to clipboard

Cannot require any modules

Open Teln0 opened this issue 4 years ago • 11 comments

OS: Ubuntu 19.10 x86_64 Kernel: 5.3.0-53-generic NectarJS v0.6.1

I cannot compile my project because of "require error"s. It happens for every module I require in my script.

nectar ./index.js --verbose [*] Generating source file [!] Require error : fs

If I remove fs, it gives me something else (the next module).

Am I missing something ?

Teln0 avatar May 24 '20 15:05 Teln0

Hi @Teln0 ,

there is no fs module for the moment, there is an fs-std module with simple functions (readFileSync, writeFileSync ...)

We will add support for the standard node ecosystem soon

adrien-thierry avatar May 24 '20 15:05 adrien-thierry

what about other modules like http ?

Teln0 avatar May 24 '20 15:05 Teln0

@Teln0 it is the same, i'm finishing the base of NectarJS, then, we will be able to add any module and platforms (libuv, node modules ...)

adrien-thierry avatar May 26 '20 06:05 adrien-thierry

@Teln0 I started the njs-http module, you can check the http.js example

adrien-thierry avatar May 31 '20 15:05 adrien-thierry

@Teln0 it is the same, i'm finishing the base of NectarJS, then, we will be able to add any module and platforms (libuv, node modules ...)

So basically, you have to port the standard library/base modules and then after that, most/all node modules should work? What kind of timeline are you looking at? I know they're never accurate. Just curious as I'd love to be able to compile a native version of gundb.

bitnom avatar Jun 09 '20 20:06 bitnom

So basically, you have to port the standard library/base modules and then after that, most/all node modules should work?

-> basically yes, i just integrated libuv for node env

What kind of timeline are you looking at? I know they're never accurate. Just curious as I'd love to be able to compile a native version of gundb.

-> i think between 3 and 6 months it will be more usable with Node, so a more things will compile

adrien-thierry avatar Jun 09 '20 21:06 adrien-thierry

Just found this project, and I think it's fantastic. Really looking forward to using it once it's more stable with Node. A preliminary compilation of console.log('Hello world') came in at just 176KB vs over 40MB with other projects that bake in the entire nodejs run time, which is amazing!

josephschmitt avatar Jun 12 '20 15:06 josephschmitt

Hi @josephschmitt ,

Thank you very much !

Arduino examples fits on Arduino nano with less than 10ko of rom, where NodeJS (or any other vm) will never fits

adrien-thierry avatar Jun 12 '20 16:06 adrien-thierry

It would be nice actually to have a list of features supported and what is on road map, instead of keeping developers hitting the wall with all kinds of strange issues.

[*] Generating source file
[!] Warning : index file of module escape-string-regexp seems empty
/usr/local/Cellar/node/14.5.0/lib/node_modules/nectarjs/compiler/native/lib/genRequire.js:208
        var _Ext = fileSource.split(".");
                              ^

TypeError: Cannot read property 'split' of undefined

and it dies on just two lines of code:

const chalk = require('chalk');
console.log(chalk.blue('hello'));

skitsanos avatar Aug 07 '20 12:08 skitsanos

Hi @skitsanos ,

Thank you for the feedback,

The full supported modules, right now, are the nectar_modules,

Before supportind nodejs modules, we are finishing to support ES3, after we will focus on the NodeJS env

The error you have right now is because one file of the module seems empty, or there is a bug, i will check it right now

adrien-thierry avatar Aug 07 '20 12:08 adrien-thierry

@skitsanos Roadmap and doc are updated

adrien-thierry avatar Aug 19 '20 08:08 adrien-thierry