why does errors show in the console when using packages like axios or googleapi or else?
Unanswered
Ashy Storm-Petrel posted this in #help-forum
![Avatar](https://cdn.discordapp.com/embed/avatars/5.png)
Ashy Storm-PetrelOP
now the app works on my local server and all but it shows error on the console of the terminal for some reason is that normal or is there a way i can fix it?
44 Replies
![Avatar](https://cdn.discordapp.com/avatars/548149742207631360/2b1e750ac12613e7f54964225371f39b.webp?size=256)
not-milo.tsx
What errors are you getting?
You need to provide a little more information, but typically you should try to keep the console free of any kind of errors/warnings.
![Avatar](https://cdn.discordapp.com/embed/avatars/5.png)
Ashy Storm-PetrelOP
i keep getting different errors with different packages
![Avatar](https://cdn.discordapp.com/avatars/548149742207631360/2b1e750ac12613e7f54964225371f39b.webp?size=256)
not-milo.tsx
Have you installed those packages?
Try running
npm install encoding
and see if the error disappears as it should.![Avatar](https://cdn.discordapp.com/embed/avatars/5.png)
Ashy Storm-PetrelOP
huh i thought stuff like this would be already installed since i got the package
i installed the packages they want and now am getting new error to import the package
when i just import like
it still shows this error
import "supports-color"
it still shows this error
![Image](https://cdn.discordapp.com/attachments/1148338432666513460/1148602457786679388/image.png)
this is the web page they reference
even then i try it it would show the same error
![Avatar](https://cdn.discordapp.com/avatars/548149742207631360/2b1e750ac12613e7f54964225371f39b.webp?size=256)
not-milo.tsx
Not all dependencies are installed automatically... If you use Supabase for example, you'll have to install encoding manually for it to work properly
![Avatar](https://cdn.discordapp.com/embed/avatars/5.png)
Ashy Storm-PetrelOP
i just asked the AI in #gpt-help and it provided something that works in the next config i added this
/** @type {import('next').NextConfig} */
const nextConfig = {
experimental: { esmExternals: "loose" },
}
module.exports = nextConfig
/** @type {import('next').NextConfig} */
const nextConfig = {
experimental: { esmExternals: "loose" },
}
module.exports = nextConfig
i see thank you for this information!
would this be idle or will it cause problems later?
![Avatar](https://cdn.discordapp.com/avatars/548149742207631360/2b1e750ac12613e7f54964225371f39b.webp?size=256)
not-milo.tsx
That option does not exist...
esmExternal
as far as I know is not a thing![Avatar](https://cdn.discordapp.com/avatars/548149742207631360/2b1e750ac12613e7f54964225371f39b.webp?size=256)
not-milo.tsx
You're not getting this error because you didn't import the package, so that won't help you
![Avatar](https://cdn.discordapp.com/embed/avatars/5.png)
Ashy Storm-PetrelOP
it fixed it somehow
am not getting any errors anymore
![Avatar](https://cdn.discordapp.com/avatars/548149742207631360/2b1e750ac12613e7f54964225371f39b.webp?size=256)
not-milo.tsx
That's werid as hell
Glad you managed to solve it anyways ✌ï¸
![Avatar](https://cdn.discordapp.com/embed/avatars/5.png)
Ashy Storm-PetrelOP
Thank you! without your note about installing the package i wouldn't get to that page lol
![Avatar](https://cdn.discordapp.com/avatars/517101361293295629/06225f1d8ea5bb8fb0f8d4fab719a366.webp?size=256)
tree🌳
Wait
I had those same errors myself a few days ago
The packages were already installed. You dont have to touch anything
Its just ur code that it has maybe hydration problems
![Avatar](https://cdn.discordapp.com/embed/avatars/5.png)
Ashy Storm-PetrelOP
and how can i check or test for that?
i tested my code in nodejs and worked perfectly fine
![Avatar](https://cdn.discordapp.com/avatars/517101361293295629/06225f1d8ea5bb8fb0f8d4fab719a366.webp?size=256)
tree🌳
If im honest im not sure. When it happened to me it was because i was calling the models in the component instead of just keeping all the models code in the api side. I was being stupid yea. Also the code was duplicated from my api call so i just deleted some lines and commented a few more and started again
But no packages were needed. I even deleted the node_modules, refreshed everything but nothing helped
![Avatar](https://cdn.discordapp.com/embed/avatars/5.png)
Ashy Storm-PetrelOP
my code is in the api side
![Avatar](https://cdn.discordapp.com/avatars/517101361293295629/06225f1d8ea5bb8fb0f8d4fab719a366.webp?size=256)
tree🌳
What does the settings.js look like. And the analytics/route file. Can u send them
![Avatar](https://cdn.discordapp.com/embed/avatars/5.png)
Ashy Storm-PetrelOP
it's basically all the settings to setup up google apis
import { NextResponse as res } from "next/server"
import Analytics from "@extra/settings"
export async function GET() {
await Analytics()
return res.json(await Analytics("facebook",'google'), { status: 200 })
}
this is api/analytics
import "dotenv/config"
let config = JSON.parse(process.env.CONFIG)
import {google} from "googleapis"
import { BetaAnalyticsDataClient } from "@google-analytics/data"
const auth = new google.auth.GoogleAuth({
credentials: config,
scopes: ["https://www.googleapis.com/auth/analytics.readonly"],
})
const analyticsDataClient = new BetaAnalyticsDataClient({ auth })
export default async function runReport(...query) {
let neededData = []
let socialMedia = []
try {
const [response] = await analyticsDataClient.runReport({
property: "properties/405050966", // Replace with your Measurement ID
dateRanges: [
{
startDate: "30daysAgo",
endDate: "today",
},
],
dimensions: [
{
name: "eventName", // Use "eventName" as the dimension to get event names
},
],
metrics: [
{
name: "eventCount", // Use "eventCount" as the metric to get event counts
},
],
orderBys: [
{
metric: {
metricName: "eventCount",
},
sortOrder: "DESCENDING", // Sort events by event count in descending order
},
],
limit: 10, // Limit the number of events returned (adjust as needed)
})
response.rows.forEach((row) => {
let wanted = row.dimensionValues[0].value
if (wanted === "first_visit") {
neededData.push({
first_visit: row.dimensionValues[0].value,
clicks: row.metricValues[0].value,
})
}
if (wanted === "page_view") {
neededData.push({
page_view: row.dimensionValues[0].value,
clicks: row.metricValues[0].value,
})
}
query.forEach((q) => {
if (wanted === q) {
socialMedia.push({
link: row.dimensionValues[0].value,
clicks: row.metricValues[0].value,
})
}
})
})
neededData.push(socialMedia)
return neededData
} catch (error) {
console.error("Error running report:", error)
}
}
this is settings.js
but the error happen as soon as i do
import {google} from "googleapis"
before important it everything was fine