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?
javascript html node.js
|
show 5 more comments
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?
javascript html node.js
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
|
show 5 more comments
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?
javascript html node.js
<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
javascript html node.js
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
|
show 5 more comments
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
|
show 5 more comments
1 Answer
1
active
oldest
votes
up vote
-1
down vote
require()
is a Node.js module, so you'll have to create a.JS
file for that.- 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>
New contributor
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 includenet
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
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
-1
down vote
require()
is a Node.js module, so you'll have to create a.JS
file for that.- 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>
New contributor
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 includenet
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
add a comment |
up vote
-1
down vote
require()
is a Node.js module, so you'll have to create a.JS
file for that.- 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>
New contributor
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 includenet
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
add a comment |
up vote
-1
down vote
up vote
-1
down vote
require()
is a Node.js module, so you'll have to create a.JS
file for that.- 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>
New contributor
require()
is a Node.js module, so you'll have to create a.JS
file for that.- 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>
New contributor
edited Nov 19 at 12:27
New contributor
answered Nov 19 at 12:25
Crist
34
34
New contributor
New contributor
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 includenet
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
add a comment |
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 includenet
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
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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