pinojs / pino-mongodb

:evergreen_tree: Insert JSON from stdin into MongoDB
MIT License
54 stars 18 forks source link

unable to determine transport target for "pino-mongodb" #122

Open toto1384 opened 2 years ago

toto1384 commented 2 years ago

The pino-mongodb library is installed

Here is the code

import pino from 'pino'
const transport = pino.transport({
    target: 'pino-mongodb',
    /* level: 'info', */
    options: {
        uri: `${(process.env.MONGODB_CONNECTION as string).split('27017')[0]}27017`,
        database: 'logs',
        collection: 'main',
        mongoOptions: {
            auth: {
                username: logins[0],
                password: logins[1]
            }
        }
    }
})

const logger = pino(transport)

Here is the error I am getting

error - Error: unable to determine transport target for "pino-mongodb"
    at fixTarget (/Users/alex/Mynextjob/CODE/complete/node_modules/.pnpm/pino@8.6.1/node_modules/pino/lib/transport.js:136:13)
    at Function.transport (/Users/alex/Mynextjob/CODE/complete/node_modules/.pnpm/pino@8.6.1/node_modules/pino/lib/transport.js:110:22)
    at eval (webpack-internal:///./utils/backend/backendMain.ts:116:63)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
  page: '/'
}
mcollina commented 2 years ago

It seems you are running webpack without the additional config for transports.

https://github.com/pinojs/pino-webpack-plugin