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.

Need a better mental model for async/await?

Check out this classic DEV post on the subject.

⭐️🎀 JavaScript Visualized: Promises & Async/Await

async await

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay