Library help for Javascript

Question: How do I add a library? Trying to convert a block-based code project to another file type, Xml to js is what I going for. I have “X2JS” but do not know how to import it

Are you asking something like this? Getting started with Node.js modules: require, exports, imports and beyond | Adrian Mejia Blog

1 Like

Maybe? I’m honestly new to everything Javascript, or code in general. So far I’m having no luck the only 2 sites, I have to help is the one you provided and the github for what I want to import. Either I can’t read, or I’m just not… something?

1 Like

Welcome to the community! is this for frontend or backend?

1 Like

I’m sorry.
I don’t know what either of those means. I’m new so explain… baby terms.
What I did was use a block-based coding program (If needed it’s “Snap!”) which saves with XML, and not want my "useless"¹ XML code to be a more readable Javascript code for me to post on replit.
My idea is to paste the XML code into a replit XML file, then put it through the imported “X2JS” library to make it Javascript, or somehow make it javascript.
I used an XML to JS Object converter but it used colins instead of semicolons.
And thanks for the welcome =]

¹ Useless because only snap can read the XML code, any other XML code snap won’t read, and snap XML can not really be read by anything. I myself don’t know Javascript so I cant write it myself, so unless I get free help (which I doubt won’t get), I’m stuck.

1 Like

oh I see. Your doing frontend. If you have the library, you can just do <script src = "library cdn url"> </script> inside your html page. EDIT: do you know html?

2 Likes

Frontend: What the user sees when they go to your page
Backend: The server, basically the user makes requests to it and the server makes a request to display html and css and stuff

If you have a HTML file, you can insert a <script> of the library you want to install in the header/top of your body in your file.

You could also install the library via npm by typing $ npm install WHATEVER_LIBRARY in the shell.

1 Like

No sadly, but what url would I put? The github page for X2JS? And If it is gonna be HTML, Im gonna need a diffrent libary because its for XML to JavaScript. Is that correct?

I think I want frontend, Its 1.5 MB XML and using a broken converter, 10 MB JavaScript. Not a big project. But it can take proscessing so maybe backend is better?

No HTML file unfortunately.

then install the library via npm: $ npm install WHATEVER_LIBRARY

Can I do this in replit?
Also apologies if Im being hard to work with, trying my best to understand with my limited knowledge and hardware.

Yes, you can. To open the shell, you will first need to create a new tab and type “shell” into the search bar. Click on the first result and start typing the library you want to install.

I did, said it needed an update, and i did. but its yelling at me for a bunch of errors. I also cant add a screenshot because it also yells at me.

EDIT: Screenshot to this reply, cant add it here.

1 Like

can i ask what library you are installing? i may be able to help you with finding out what’s wrong.

X2JS by Maxouhell (Github name)
[ Github ] [ npm ]
(I never heard or npm until you said it but i now realizied that its also a site and not a downloadable program)

it seems to be alright with installing the library. if it asks for an update, it should still be okay to run it.

if you want to be sure, you can just type the npm command it gave before the last npm notice.

I will try on a new repl project, install the libary (or try), and report back.

EDIT: What template should I use? Javascript?
EDIT2: Ill use the “HTML, CSS, JS”

Reporting back:
Report: I was able it add without errors, but only when I typed “npm install -g npm@9.4.2” did I get errors.

EDIT: It also asked me to add node.js and I added nodejs-16_x
EDIT2: Ive also reached a max number of replys? Ill add what ill report to using a nodejs template @dragonhunter1
EDIT3: It worked! Ill try to look around and figure things out and if I get nowhere, Ill come back.
EDIT4: Yea no. So I have a libary, but both npm and github isnt being helpful, I have the github file, so do i upload anything? When i run the “quickstart” code, it gives me an error.

1 Like