Using net = require('net') in html











up vote
0
down vote

favorite












<script>
var net;
try{
net = require('net');
}catch(e){
alert(e)
}
</script>


It shows this error ReferenceError: require is not defined. Should I import any other module?










share|improve this question
























  • require() is of node.js, you can't use it in the client-side without libraries such as require.js.
    – Chayim Friedman
    Nov 19 at 12:15






  • 1




    Also, net is a module of node.js, it's not a part of the standards of js... I assume there are similar libraries in the network, you can try Google it.
    – Chayim Friedman
    Nov 19 at 12:17










  • Thank you, I had try google already. However i got something like your helping's answer but i still confuse. Thank you by the way.
    – Just a pokemon trainer
    Nov 19 at 12:21












  • net implements functionality that a browser doesn't support, like making generic network connections.
    – robertklep
    Nov 19 at 12:43










  • @robertklep i google it a lot. However, i can't find solution.
    – Just a pokemon trainer
    Nov 19 at 13:13















up vote
0
down vote

favorite












<script>
var net;
try{
net = require('net');
}catch(e){
alert(e)
}
</script>


It shows this error ReferenceError: require is not defined. Should I import any other module?










share|improve this question
























  • require() is of node.js, you can't use it in the client-side without libraries such as require.js.
    – Chayim Friedman
    Nov 19 at 12:15






  • 1




    Also, net is a module of node.js, it's not a part of the standards of js... I assume there are similar libraries in the network, you can try Google it.
    – Chayim Friedman
    Nov 19 at 12:17










  • Thank you, I had try google already. However i got something like your helping's answer but i still confuse. Thank you by the way.
    – Just a pokemon trainer
    Nov 19 at 12:21












  • net implements functionality that a browser doesn't support, like making generic network connections.
    – robertklep
    Nov 19 at 12:43










  • @robertklep i google it a lot. However, i can't find solution.
    – Just a pokemon trainer
    Nov 19 at 13:13













up vote
0
down vote

favorite









up vote
0
down vote

favorite











<script>
var net;
try{
net = require('net');
}catch(e){
alert(e)
}
</script>


It shows this error ReferenceError: require is not defined. Should I import any other module?










share|improve this question















<script>
var net;
try{
net = require('net');
}catch(e){
alert(e)
}
</script>


It shows this error ReferenceError: require is not defined. Should I import any other module?







javascript html node.js






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 19 at 12:23









Rohan Dhar

461210




461210










asked Nov 19 at 12:14









Just a pokemon trainer

134




134












  • require() is of node.js, you can't use it in the client-side without libraries such as require.js.
    – Chayim Friedman
    Nov 19 at 12:15






  • 1




    Also, net is a module of node.js, it's not a part of the standards of js... I assume there are similar libraries in the network, you can try Google it.
    – Chayim Friedman
    Nov 19 at 12:17










  • Thank you, I had try google already. However i got something like your helping's answer but i still confuse. Thank you by the way.
    – Just a pokemon trainer
    Nov 19 at 12:21












  • net implements functionality that a browser doesn't support, like making generic network connections.
    – robertklep
    Nov 19 at 12:43










  • @robertklep i google it a lot. However, i can't find solution.
    – Just a pokemon trainer
    Nov 19 at 13:13


















  • require() is of node.js, you can't use it in the client-side without libraries such as require.js.
    – Chayim Friedman
    Nov 19 at 12:15






  • 1




    Also, net is a module of node.js, it's not a part of the standards of js... I assume there are similar libraries in the network, you can try Google it.
    – Chayim Friedman
    Nov 19 at 12:17










  • Thank you, I had try google already. However i got something like your helping's answer but i still confuse. Thank you by the way.
    – Just a pokemon trainer
    Nov 19 at 12:21












  • net implements functionality that a browser doesn't support, like making generic network connections.
    – robertklep
    Nov 19 at 12:43










  • @robertklep i google it a lot. However, i can't find solution.
    – Just a pokemon trainer
    Nov 19 at 13:13
















require() is of node.js, you can't use it in the client-side without libraries such as require.js.
– Chayim Friedman
Nov 19 at 12:15




require() is of node.js, you can't use it in the client-side without libraries such as require.js.
– Chayim Friedman
Nov 19 at 12:15




1




1




Also, net is a module of node.js, it's not a part of the standards of js... I assume there are similar libraries in the network, you can try Google it.
– Chayim Friedman
Nov 19 at 12:17




Also, net is a module of node.js, it's not a part of the standards of js... I assume there are similar libraries in the network, you can try Google it.
– Chayim Friedman
Nov 19 at 12:17












Thank you, I had try google already. However i got something like your helping's answer but i still confuse. Thank you by the way.
– Just a pokemon trainer
Nov 19 at 12:21






Thank you, I had try google already. However i got something like your helping's answer but i still confuse. Thank you by the way.
– Just a pokemon trainer
Nov 19 at 12:21














net implements functionality that a browser doesn't support, like making generic network connections.
– robertklep
Nov 19 at 12:43




net implements functionality that a browser doesn't support, like making generic network connections.
– robertklep
Nov 19 at 12:43












@robertklep i google it a lot. However, i can't find solution.
– Just a pokemon trainer
Nov 19 at 13:13




@robertklep i google it a lot. However, i can't find solution.
– Just a pokemon trainer
Nov 19 at 13:13












1 Answer
1






active

oldest

votes

















up vote
-1
down vote















  1. require() is a Node.js module, so you'll have to create a .JS file for that.

  2. the .JS file can have ANY name.


Fixed Code (for the .JS file):



try {
const net = require('net');
}catch(e){
console.log(e)
}


HTML Code (to request the .JS file's settings):



<script src="/YOUR_FILE_NAME.js" defer></script>





share|improve this answer










New contributor




Crist is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.


















  • Your code does not make sense. Why empty try-catch body?
    – Justinas
    Nov 19 at 12:27










  • @Justinas sorry for that mess, I forgot to include net inside the function.
    – Crist
    Nov 19 at 12:31










  • @Justinas I had try this already, but still got similar error. Thank you by the way.
    – Just a pokemon trainer
    Nov 19 at 12:32












  • @Justinas I just debug it's error, So i wrap it with try catch.
    – Just a pokemon trainer
    Nov 19 at 12:33













Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














 

draft saved


draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53374421%2fusing-net-requirenet-in-html%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
-1
down vote















  1. require() is a Node.js module, so you'll have to create a .JS file for that.

  2. the .JS file can have ANY name.


Fixed Code (for the .JS file):



try {
const net = require('net');
}catch(e){
console.log(e)
}


HTML Code (to request the .JS file's settings):



<script src="/YOUR_FILE_NAME.js" defer></script>





share|improve this answer










New contributor




Crist is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.


















  • Your code does not make sense. Why empty try-catch body?
    – Justinas
    Nov 19 at 12:27










  • @Justinas sorry for that mess, I forgot to include net inside the function.
    – Crist
    Nov 19 at 12:31










  • @Justinas I had try this already, but still got similar error. Thank you by the way.
    – Just a pokemon trainer
    Nov 19 at 12:32












  • @Justinas I just debug it's error, So i wrap it with try catch.
    – Just a pokemon trainer
    Nov 19 at 12:33

















up vote
-1
down vote















  1. require() is a Node.js module, so you'll have to create a .JS file for that.

  2. the .JS file can have ANY name.


Fixed Code (for the .JS file):



try {
const net = require('net');
}catch(e){
console.log(e)
}


HTML Code (to request the .JS file's settings):



<script src="/YOUR_FILE_NAME.js" defer></script>





share|improve this answer










New contributor




Crist is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.


















  • Your code does not make sense. Why empty try-catch body?
    – Justinas
    Nov 19 at 12:27










  • @Justinas sorry for that mess, I forgot to include net inside the function.
    – Crist
    Nov 19 at 12:31










  • @Justinas I had try this already, but still got similar error. Thank you by the way.
    – Just a pokemon trainer
    Nov 19 at 12:32












  • @Justinas I just debug it's error, So i wrap it with try catch.
    – Just a pokemon trainer
    Nov 19 at 12:33















up vote
-1
down vote










up vote
-1
down vote











  1. require() is a Node.js module, so you'll have to create a .JS file for that.

  2. the .JS file can have ANY name.


Fixed Code (for the .JS file):



try {
const net = require('net');
}catch(e){
console.log(e)
}


HTML Code (to request the .JS file's settings):



<script src="/YOUR_FILE_NAME.js" defer></script>





share|improve this answer










New contributor




Crist is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











  1. require() is a Node.js module, so you'll have to create a .JS file for that.

  2. the .JS file can have ANY name.


Fixed Code (for the .JS file):



try {
const net = require('net');
}catch(e){
console.log(e)
}


HTML Code (to request the .JS file's settings):



<script src="/YOUR_FILE_NAME.js" defer></script>






share|improve this answer










New contributor




Crist is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this answer



share|improve this answer








edited Nov 19 at 12:27





















New contributor




Crist is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









answered Nov 19 at 12:25









Crist

34




34




New contributor




Crist is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





Crist is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






Crist is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












  • Your code does not make sense. Why empty try-catch body?
    – Justinas
    Nov 19 at 12:27










  • @Justinas sorry for that mess, I forgot to include net inside the function.
    – Crist
    Nov 19 at 12:31










  • @Justinas I had try this already, but still got similar error. Thank you by the way.
    – Just a pokemon trainer
    Nov 19 at 12:32












  • @Justinas I just debug it's error, So i wrap it with try catch.
    – Just a pokemon trainer
    Nov 19 at 12:33




















  • Your code does not make sense. Why empty try-catch body?
    – Justinas
    Nov 19 at 12:27










  • @Justinas sorry for that mess, I forgot to include net inside the function.
    – Crist
    Nov 19 at 12:31










  • @Justinas I had try this already, but still got similar error. Thank you by the way.
    – Just a pokemon trainer
    Nov 19 at 12:32












  • @Justinas I just debug it's error, So i wrap it with try catch.
    – Just a pokemon trainer
    Nov 19 at 12:33


















Your code does not make sense. Why empty try-catch body?
– Justinas
Nov 19 at 12:27




Your code does not make sense. Why empty try-catch body?
– Justinas
Nov 19 at 12:27












@Justinas sorry for that mess, I forgot to include net inside the function.
– Crist
Nov 19 at 12:31




@Justinas sorry for that mess, I forgot to include net inside the function.
– Crist
Nov 19 at 12:31












@Justinas I had try this already, but still got similar error. Thank you by the way.
– Just a pokemon trainer
Nov 19 at 12:32






@Justinas I had try this already, but still got similar error. Thank you by the way.
– Just a pokemon trainer
Nov 19 at 12:32














@Justinas I just debug it's error, So i wrap it with try catch.
– Just a pokemon trainer
Nov 19 at 12:33






@Justinas I just debug it's error, So i wrap it with try catch.
– Just a pokemon trainer
Nov 19 at 12:33




















 

draft saved


draft discarded



















































 


draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53374421%2fusing-net-requirenet-in-html%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

404 Error Contact Form 7 ajax form submitting

How to know if a Active Directory user can login interactively

Refactoring coordinates for Minecraft Pi buildings written in Python