Calling another file function, NODE

Asked

Viewed 572 times

-2

Erro que está sendo gerado Good afternoon, I would like to know how to pull the function of a mini-program to a program in JS, check Note.js containing the function verificaNota, I would like to know how to pull this function in the file calculatNota.js

When I last import it generates the following error

SyntaxError: Unexpected token {
  • 1

    The archive verificaNota.js is exposing the function verificaNota through the export?

  • No, how do I expose ?

  • See the link from the previous comment.

  • @Andersoncarloswoss followed the steps but is now generating the error attached in the image

  • It seems that on the Node you will use the require.

  • @Andersoncarloswoss I used require and it worked obg friend, abs

Show 1 more comment

1 answer

0

I managed to solve, I turned the function into a variable and named it like this exports.verificaNota, then opened in the second program and inserted the following command var nota = require('./verificaNota') , now to call the function I use nota.verificaNota(8,1)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.