Jacques Marais
Jacques Marais

Reputation: 188

Can NodeJS be used on the web instead of the command-line

When developing a website and doing some server-side stuff with NodeJS can NodeJS be used on the command-line only or can it be used for scripting too? For example creating a script and doing all my NodeJS stuff in there and then including the script in my HTML without the command-line or is this not possible?

Upvotes: 0

Views: 94

Answers (2)

Kamrul
Kamrul

Reputation: 7301

try node-browserify @ https://github.com/substack/node-browserify, which i guess a bit closer to what you wanted here.

Upvotes: 1

Quentin
Quentin

Reputation: 943097

You can't embed Node.js in a webpage, but browsers have built in JavaScript runtimes so you don't need to embed another one.

You can't use Node.js specific APIs from JavaScript in a webpage. Most of them have serious security implications (such as providing a means for JavaScript to access the filesystem).

You can use Node.js to run an HTTP server, which you can then access from the browser (both directly and via XMLHttpRequest).

Upvotes: 2

Related Questions