You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm newbie at JS
I tried to write very simple JS just to load response body from REST service and parse ANSI text into HTML and got stuck at the Usage example:
Usage
var Convert = require('ansi-to-html');
var convert = new Convert();
This is because require() does not exist in the browser/client-side JavaScript.
Now you're going to have to make some choices about your client-side JavaScript script management.
You have three options:
Use the <script> tag.
Use a CommonJS implementation. It has synchronous dependencies like Node.js
Use an asynchronous module definition (AMD) implementation.
CommonJS client side-implementations include (most of them require a build step before you deploy):
Browserify - You can use most Node.js modules in the browser. This is my personal favorite.
Webpack - Does everything (bundles JavaScript code, CSS, etc.). It was made popular by the surge of React, but it is notorious for its difficult learning curve.
Rollup - a new contender. It leverages ES6 modules and includes tree-shaking abilities (removes unused code).
You can read more about my comparison of Browserify vs (deprecated) Component.
AMD implementations include:
RequireJS - Very popular amongst client-side JavaScript developers. It is not my taste because of its asynchronous nature.
Note, in your search for choosing which one to go with, you'll read about Bower. Bower is only for package dependencies and is unopinionated on module definitions like CommonJS and AMD.`
OMG...
Use the <script> tag - I'd happy to use it ... but how to use it?
Is it possible to create a README for Dummies ? Is it possible to create just single script for ansi-to-html coverting?
The text was updated successfully, but these errors were encountered:
I'm newbie at JS
I tried to write very simple JS just to load response body from REST service and parse ANSI text into HTML and got stuck at the Usage example:
Usage
var Convert = require('ansi-to-html');
var convert = new Convert();
console.log(convert.toHtml('\x1b[30mblack\x1b[37mwhite'));
/*
prints: ...
*/
Got an exception:
Uncaught ReferenceError: require is not defined
Googling tries at stackoverflow also made me hurt:
https://stackoverflow.com/questions/19059580/client-on-node-js-uncaught-referenceerror-require-is-not-defined
`10 Answers
This is because require() does not exist in the browser/client-side JavaScript.
Now you're going to have to make some choices about your client-side JavaScript script management.
You have three options:
Use the <script> tag.
Use a CommonJS implementation. It has synchronous dependencies like Node.js
Use an asynchronous module definition (AMD) implementation.
CommonJS client side-implementations include (most of them require a build step before you deploy):
Browserify - You can use most Node.js modules in the browser. This is my personal favorite.
Webpack - Does everything (bundles JavaScript code, CSS, etc.). It was made popular by the surge of React, but it is notorious for its difficult learning curve.
Rollup - a new contender. It leverages ES6 modules and includes tree-shaking abilities (removes unused code).
You can read more about my comparison of Browserify vs (deprecated) Component.
AMD implementations include:
RequireJS - Very popular amongst client-side JavaScript developers. It is not my taste because of its asynchronous nature.
Note, in your search for choosing which one to go with, you'll read about Bower. Bower is only for package dependencies and is unopinionated on module definitions like CommonJS and AMD.`
OMG...
Use the <script> tag - I'd happy to use it ... but how to use it?
Is it possible to create a README for Dummies ? Is it possible to create just single script for ansi-to-html coverting?
The text was updated successfully, but these errors were encountered: