Invalid or Unexpected token

Asked

Viewed 301 times

0

When trying to execute the code below

fetch(`https://mktp.oversystem.com.br:8443/MKTPlace2/rest/sinistrosZurich`, {
      method: "GET",
      header: {
        "Access-token": "aC0009E000081007F400dF210",
        "Content-Type": "application/json",
      },
    }
  )
  .then((response) => {
    console.log(response)
  })
  .catch((err) => {
    console.error("Erro: ", err);
  });

Or even a simpler code, like the one below, just to test if my Node is running a micro service.

const fetch = require('node-fetch')
const url='https://httpbin.org/get'
fetch(url).then((res)=>{
  console.log(res)
})

I am getting the following error while executing the command node app.js in Powershell

SyntaxError: Invalid or unexpected token
[90m    at wrapSafe (internal/modules/cjs/loader.js:979:16)[39m
[90m    at Module._compile (internal/modules/cjs/loader.js:1027:27)[39m
[90m    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)[39m
[90m    at Module.load (internal/modules/cjs/loader.js:928:32)[39m
[90m    at Function.Module._load (internal/modules/cjs/loader.js:769:14)[39m
[90m    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)[39m
[90m    at internal/main/run_main_module.js:17:47[39m]

Can you tell me what might be wrong?

I already uninstalled Node.js and installed again I’ve created some environment variables

NODE_ENV = Development NODE_PATH = C: node_modules

I also do not know if the environment variables are correct...

  • Could be the encoding of your file app js., check which one is and try to save as UTF-8 to see if it works.

1 answer

1


For environment variables, the = should stick to the words:

NODE_ENV=Development&& NODE_PATH=C: node_modules

but I don’t know if that’s the reason for the mistake. isolated codes are ok, I tested both here.

the error is in some other part that you have not shown here.

Browser other questions tagged

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