So I have this logs in my server.js
file:
console.info("LOOGGGGGSSSS")
console.warn("LOOGGGGGSSSS")
console.log("LOOGGGGGSSSS")
console.error("LOOGGGGGSSSS")
My package.json
has script:
"scripts": {
"dev": "next",
"start": "next start"
}
When I run server with npm run start all works correctly and I can see logs but with npm run dev
no console.log()
or console.error()
works at all.
I tried with option quiet true and false but still not working:
const nextJsApp = next({dev, quiet: false}); // no logs in terminal
and
const nextJsApp = next({dev, quiet: true}); // still no logs in terminal
My next.config.js
require("dotenv").config();
const withCSS = require('@zeit/next-css');
const webpack = require('webpack');
const apiKey = JSON.stringify(process.env.SHOPIFY_API_KEY);
module.exports = withCSS({
webpack: (config) => {
const env = { SHOPIFY_API_KEY: apiKey };
config.plugins.push(new webpack.DefinePlugin(env));
return config;
},
});
Go to the terminal where you ran npm run dev
.
You should be able to see your console log there.
I used the package cross-env to avoid some issue when working with different OS.
"dev": "cross-env NODE_OPTIONS='--inspect' next dev"
Works just fine, I can now see all my logs mixed with Next logs.
If you want to see your server logs in local development mode, you do not need to use your own server. You can edit the dev Script in your package.json like this:
"dev": "NODE_OPTIONS='--inspect' next dev",
and when you run your dev (npm run dev
) you can go in Chrome to: chrome://inspect
.
At the bottom under remote target, click on inspect
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With