0

When I remove the import line, all works fine (except that it doesn't find the imported functions, of course). But when I take the import in, it says "Uncaught ReferenceError: myFunction is not defined".

import io from 'socket.io-client';

function myFunction(name) {
    setTimeout(function() {
        mydel(name)

    }, 2000);
    print(name);
    sendOrder(name);
}

(I took the rest of the code out)

Am I doing some syntax wrong? Couldn't find the error

1
  • The error message "Uncaught ReferenceError: myFunction is not defined" occurs when you try to call the function. You haven't shown us how you call myFunction. You've only shown us a definition. Please include a good deal more code. Is myFunction in a module? Is it trying to call something from socket.io-client? There is not enough information provided here. Commented Sep 13, 2019 at 18:10

3 Answers 3

1

Are you use Node to run this Code or you want to run this code on the other environments? if it's node, check your node version with this command:

node -v

your node must support import Keyword

don't forget to call Function, maybe it's your problem.

Sign up to request clarification or add additional context in comments.

Comments

0

Have you tried using:

const io = require('socket.io-client');

Comments

0

Try out this method ,

Step 1 ) npm i socket.io-client --save

Step 2 ) 
    import ioClient from 'socket.io-client'

    let io = ioClient('http://your-host');

For more details , visit the npm documentation and another git hub solutoin

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.