Reputation: 57
I would like to run Node.js in my webpage, the same way that you would with PHP or ASP.NET.
The reason for this is I would like to use require()'d modules from NPM in my browser javascript, however vanilla JS doesn't seem to support this. Is there any way I can run Node.js in my tags? If not, would requiring examplenodefile.js in my browser javascript work?
Edit: Is there any alternative to this, if it isn't possible? I know I can set script src
but that doesn't really work as nicely as var foo = require('bar');
Upvotes: 3
Views: 6384
Reputation: 144
From your above question I am assuming you want to use NPM modules in your browser side JavaScript. This is possible to do assuming you have web pack. You can use webpack to bundle the NPM packages inside a bundle file.
Check out webpack...
Upvotes: 4