I’m trying to build a package in OS.js at the moment, and I wanted to use fs.js: https://github.com/zlatinejc/fs
I have installed fs.js using npm, and it works on my computer, but I’m not sure how to use it with a package. when I refer to fs in my main.js file, it says that fs does not exist, and when I add in ‘var fs = require’ the application doesn’t open at all.
I thought I needed to add ‘const fs = require(‘fs’);’ to the grunt file, but that isn’t working either.
I don’t understand how to get OS.js to use an external package, after I have installed it (globally) with npm. Any help is appreciated!
master branch of OS.js does not use requirejs or anything like that, so if you do not build your application using webpack or anything like that, you’d have to load the file via
metadata.jsons preload section.
Now, I’m working on a full conversion to Webpack+ES6 (Babel) that has
require and all the other goods out of the box. https://github.com/os-js/OS.js/issues/617 So if you’re feeling experimental, check that out! (It’s working just fine I just gotta wrap up some stuff before releasing)
Thanks for your reply!
Are there any differences between installing the webpack version of OS.js and the master branch? I tried to install it the same way, but now when I try to build I get an error:
'Invalid configuration object,.Webpack has been initialised using a configuration object that does not match the API schema -configuration.output.path: The provided value “D:/Os.js/dist” is not an absolute path!'
Do I need to install a certain version of webpack before I build Os.js?
Thanks again for your help!
Ah, you’re on Windows. I’ll look at that tomorrow and let you know when it is fixed
I forgot to mention that the difference is that it is in ES6 and Webpack instead of pure ES5 and a custom build system.
You just need the latest Webpack. I’ll update the INSTALL file as well and get back to you.
Alright! I think I’ve fixed all the issues regarding Windows. So if you do:
$ git pull $ npm install $ node osjs build --debug
it should complete without any errors
This works for me, thank you for your help!
This is the manual for this realease btw: https://manual.os-js.org/
You might find something of interest in there.
Also, make sure to upgrade to the latest release. A few users reported some bugs that was fixed. So now everything is hopefully solid!
If you encounter any issues, don’t hesitate to send me a message!