MercadoPago error when creating preference in check out pro

119 views Asked by At

I am trying to make my project in the paid market using check out pro, but as soon as I want to import the paid market, to be able to put the variable in which the access token goes and there I can start the node index.js, but when I make the node index .js in the terminal I get this error:

Console:

```
PS C:\Users\Usuario\Escritorio\Check\webinar> node index.js
(node:620) Warning: To load an ES module, set "type": "module" in the package.json or 
use the .mjs extension.
(Use `node --trace-warnings ...` to show where the warning was created)
C:\Users\Usuario\Escritorio\Check\webinar\index.js:2
import MercadoPago from 'mercadopago';
^^^^^^

SyntaxError: Cannot use import statement outside a module
    at internalCompileFunction (node:internal/vm:73:18)
    at wrapSafe (node:internal/modules/cjs/loader:1149:20)
    at Module._compile (node:internal/modules/cjs/loader:1190:27)
    at Module._extensions..js (node:internal/modules/cjs/loader:1280:10)
    at Module.load (node:internal/modules/cjs/loader:1089:32)
    at Module._load (node:internal/modules/cjs/loader:930:12)
    at Function.executeUserEntryPoint [as runMain] 
(node:internal/modules/run_main:81:12)
    at node:internal/main/run_main_module:23:47
```

my index.js is:

// Agrega credenciales
import MercadoPago from 'mercadopago';

const client = new MercadoPago({ accessToken: 'access_token' });

app.get('/', (req, res) =>{
    res.send('Hola')
})

app.listen(port, () =>{
    console.log('escuchando en puerto ${port}')
})

my package.json is:

{
  "name": "webinar",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
  "cors": "^2.8.5",
  "express": "^4.18.2",
  "mercadopago": "^2.0.1"
  }
}




I've been watching a lot of courses on YouTube and I don't have a solution to any of them. I always stay in this part, at the beginning, at the first import from Mercadopago, since it was updated very recently and the way of integration changed. If you could help me I would be very grateful, it is for a serious and important project that I am working on, in advance, thank you very much, and greetings. Fausto Fernandez S

0

There are 0 answers