Error: Cannot find module
Unanswered
Northeast Congo Lion posted this in #help-forum
Northeast Congo LionOP
Need help. I am trying to use App router here.
Error says Cannot find module
Now, the
This is the code in
// app/api/captions/route.ts
Error says Cannot find module
error Error: Cannot find module 'C:\path\to\project\packages\frontend\public\google\client.json'
at webpackEmptyContext (C:\path\to\project\packages\frontend\.next\server\app\api\captions\route.js:22:10)Now, the
client.json file is placed in public/google directory and I'm trying to access it in api route.tsThis is the code in
route.ts// app/api/captions/route.ts
import { google } from "googleapis";
import { authenticate } from "@google-cloud/local-auth";
import path from "path";
export async function GET() {
const auth = await authenticate({
keyfilePath: path.resolve("public", "google", "client.json"),
scopes: ["https://www.googleapis.com/auth/youtube"],
});
google.options({ auth });
console.log(auth);
}1 Reply
@Northeast Congo Lion Need help. I am trying to use App router here.
Error says **Cannot find module**
`error Error: Cannot find module 'C:\path\to\project\packages\frontend\public\google\client.json'
at webpackEmptyContext (C:\path\to\project\packages\frontend\.next\server\app\api\captions\route.js:22:10)`
Now, the `client.json` file is placed in `public/google` directory and I'm trying to access it in api route.ts
This is the code in `route.ts`
// app/api/captions/route.ts
js
import { google } from "googleapis";
import { authenticate } from "@google-cloud/local-auth";
import path from "path";
export async function GET() {
const auth = await authenticate({
keyfilePath: path.resolve("public", "google", "client.json"),
scopes: ["https://www.googleapis.com/auth/youtube"],
});
google.options({ auth });
console.log(auth);
}
hi, add these to your
next.config.js/** @type {import('next').NextConfig} */
const nextConfig = {
experimental: {
serverComponentsExternalPackages: ['googleapis', '@google-cloud/local-auth'],
},
}
module.exports = nextConfig