It’s a libary so I can load it in browser directly. It’s also a npm package, but how can I use it as a moudule?
In browser, load a js file will change the objects easily, but is not the same while working in nodejs, and I can’t figure it out.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Sugar isn’t used as a standard CommonJS module, as the entire point of the library is to modify built-in prototypes. One you require it into your project, all the built-in objects will be extended and you can use them from there.Edit: This is now no longer true as of v2.0.0. Prototype modification is now opt-in so you can use Sugar just like any other node module using the exported object. For more, see https://sugarjs.com/quickstart/