DEV Community

MilesWK
MilesWK

Posted on

Node.js as a normal script.js file

Hi! So I want to use Node.js, but I wanted to know if I can turn a normal script.js file into a node.js file. For example, can I just run this to add node.js onto my HTML website:

<script src="script.js"></script>
Enter fullscreen mode Exit fullscreen mode

and have it normally act as a JS file?

Thanks!

Top comments (2)

Collapse
 
kozato_keizo_4b664b53d836 profile image
Kozato Keizo

No

Collapse
 
tr11 profile image
Tiago Rangel

No, that would be a client-side script. You need to switch to using a server instead of a static website and install Node.js on that server. It comes pre-installed on glitch, but you need to add a package.json file.

11 Tips That Make You a Better Typescript Programmer

typescript

1 Think in {Set}

Type is an everyday concept to programmers, but it’s surprisingly difficult to define it succinctly. I find it helpful to use Set as a conceptual model instead.

#2 Understand declared type and narrowed type

One extremely powerful typescript feature is automatic type narrowing based on control flow. This means a variable has two types associated with it at any specific point of code location: a declaration type and a narrowed type.

#3 Use discriminated union instead of optional fields

...

Read the whole post now!