philip.2000
TTCTheo's Typesafe Cult
•Created by philip.2000 on 6/29/2023 in #questions
Can't resolve 'fs' but in an API route???
Any idea why this error is occuring? I thought all api routes are node compatible...
Thanks a lot
Module not found: Can't resolve 'fs'
https://nextjs.org/docs/messages/module-not-found
Import trace for requested module:
./node_modules/langchain/dist/document_loaders/fs/pdf.js
./node_modules/langchain/document_loaders/fs/pdf.js
./src/app/api/chat/route.ts
./node_modules/next/dist/build/webpack/loaders/next-edge-app-route-loader/index.js?absolutePagePath=%2Fhome%2Fphilip%2Fpersonal%2Faiwirk%2Fsrc%2Fapp%2Fapi%2Fchat%2Froute.ts&page=%2Fapi%2Fchat%2Froute&appDirLoader=bmV4dC1hcHAtbG9hZGVyP25hbWU9YXBwJTJGYXBpJTJGY2hhdCUyRnJvdXRlJnBhZ2U9JTJGYXBpJTJGY2hhdCUyRnJvdXRlJmFwcFBhdGhzPSZwYWdlUGF0aD1wcml2YXRlLW5leHQtYXBwLWRpciUyRmFwaSUyRmNoYXQlMkZyb3V0ZS50cyZhcHBEaXI9JTJGaG9tZSUyRnBoaWxpcCUyRnBlcnNvbmFsJTJGYWl3aXJrJTJGc3JjJTJGYXBwJnBhZ2VFeHRlbnNpb25zPXRzeCZwYWdlRXh0ZW5zaW9ucz10cyZwYWdlRXh0ZW5zaW9ucz1qc3gmcGFnZUV4dGVuc2lvbnM9anMmcm9vdERpcj0lMkZob21lJTJGcGhpbGlwJTJGcGVyc29uYWwlMkZhaXdpcmsmaXNEZXY9dHJ1ZSZ0c2NvbmZpZ1BhdGg9dHNjb25maWcuanNvbiZiYXNlUGF0aD0mYXNzZXRQcmVmaXg9Jm5leHRDb25maWdPdXRwdXQ9JnByZWZlcnJlZFJlZ2lvbj0mbWlkZGxld2FyZUNvbmZpZz1lMzAlM0Qh&nextConfigOutput=&preferredRegion=&middlewareConfig=e30%3D!
Module not found: Can't resolve 'fs'
https://nextjs.org/docs/messages/module-not-found
Import trace for requested module:
./node_modules/langchain/dist/document_loaders/fs/pdf.js
./node_modules/langchain/document_loaders/fs/pdf.js
./src/app/api/chat/route.ts
./node_modules/next/dist/build/webpack/loaders/next-edge-app-route-loader/index.js?absolutePagePath=%2Fhome%2Fphilip%2Fpersonal%2Faiwirk%2Fsrc%2Fapp%2Fapi%2Fchat%2Froute.ts&page=%2Fapi%2Fchat%2Froute&appDirLoader=bmV4dC1hcHAtbG9hZGVyP25hbWU9YXBwJTJGYXBpJTJGY2hhdCUyRnJvdXRlJnBhZ2U9JTJGYXBpJTJGY2hhdCUyRnJvdXRlJmFwcFBhdGhzPSZwYWdlUGF0aD1wcml2YXRlLW5leHQtYXBwLWRpciUyRmFwaSUyRmNoYXQlMkZyb3V0ZS50cyZhcHBEaXI9JTJGaG9tZSUyRnBoaWxpcCUyRnBlcnNvbmFsJTJGYWl3aXJrJTJGc3JjJTJGYXBwJnBhZ2VFeHRlbnNpb25zPXRzeCZwYWdlRXh0ZW5zaW9ucz10cyZwYWdlRXh0ZW5zaW9ucz1qc3gmcGFnZUV4dGVuc2lvbnM9anMmcm9vdERpcj0lMkZob21lJTJGcGhpbGlwJTJGcGVyc29uYWwlMkZhaXdpcmsmaXNEZXY9dHJ1ZSZ0c2NvbmZpZ1BhdGg9dHNjb25maWcuanNvbiZiYXNlUGF0aD0mYXNzZXRQcmVmaXg9Jm5leHRDb25maWdPdXRwdXQ9JnByZWZlcnJlZFJlZ2lvbj0mbWlkZGxld2FyZUNvbmZpZz1lMzAlM0Qh&nextConfigOutput=&preferredRegion=&middlewareConfig=e30%3D!
"dependencies": {
"@types/node": "20.3.2",
"@types/react": "18.2.14",
"@types/react-dom": "18.2.6",
"autoprefixer": "10.4.14",
"eslint": "8.43.0",
"eslint-config-next": "13.4.7",
"langchain": "^0.0.99",
"next": "13.4.7",
"pdf-parse": "^1.1.1",
"postcss": "8.4.24",
"react": "18.2.0",
"react-dom": "18.2.0",
"tailwindcss": "3.3.2",
"typescript": "5.1.6",
"zlib": "^1.0.5"
}
"dependencies": {
"@types/node": "20.3.2",
"@types/react": "18.2.14",
"@types/react-dom": "18.2.6",
"autoprefixer": "10.4.14",
"eslint": "8.43.0",
"eslint-config-next": "13.4.7",
"langchain": "^0.0.99",
"next": "13.4.7",
"pdf-parse": "^1.1.1",
"postcss": "8.4.24",
"react": "18.2.0",
"react-dom": "18.2.0",
"tailwindcss": "3.3.2",
"typescript": "5.1.6",
"zlib": "^1.0.5"
}
10 replies
TTCTheo's Typesafe Cult
•Created by philip.2000 on 3/5/2023 in #questions
Type interface of map error
interface TableData {
[databaseName: string]: number;
}
function foo(): TableData {
let tableData = new Map<TableData>();
// No overload expects 1 type arguments, but overloads do exist that expect either 0 or 2 type arguments.
tableData.set('database1', 123);
return tableData
}
interface TableData {
[databaseName: string]: number;
}
function foo(): TableData {
let tableData = new Map<TableData>();
// No overload expects 1 type arguments, but overloads do exist that expect either 0 or 2 type arguments.
tableData.set('database1', 123);
return tableData
}
new Map<string, number>()
but why not by using the interface? Thanks!4 replies