Nic Luciano
10/21/2021, 12:59 PMnode_modules
.
i am having 2 strange issues. any help with either one would be amazing, i suspect they are related.
i apologize for the wall of text, it's mostly debug output!!!
a quick tour of the monorepo:
rpphub/node_modules/@prisma
rpphub/package.json
db workspace source (the prisma project):
rpphub/workspaces/db/package.json
rpphub/workspaces/db/schema.prisma
rpphub/workspaces/db/migrations/*
rpphub/workspaces/db/lib (client output goes here)
rpphub/workspaces/db/lib/index.js
rpphub/workspaces/db/lib/schema.prisma
rpphub/workspaces/db/lib/[...the rest of the generated files..]
and finally a nextjs app trying to utilize prisma client:
rpphub/workspaces/web
furthermore, my rpphub/workspaces/db/package.json
contains inclusion directives:
"main": "lib/index.js",
"browser": "lib/index-browser.js",
"types": "lib/index.d.ts"
***issue 1***:
the client does not work from the node REPL for certain working directories.
if i am in the rpphub/workspaces/db
directory i can have the following session:
$:~/Code/rpphub/workspaces/db$ node
Welcome to Node.js v14.15.4.
Type ".help" for more information.
> const plib = require('.')
undefined
> const client = new plib.PrismaClient()
undefined
but if i am in the rpphub
directory, a similar session fails:
$:~/Code/rpphub$ node
Welcome to Node.js v14.15.4.
Type ".help" for more information.
> const plib = require('./workspaces/db')
undefined
> const client = new plib.PrismaClient()
Uncaught:
Error: ENOENT: no such file or directory, open '/home/nic/Code/rpphub/.git/schema.prisma'
at Object.openSync (fs.js:476:3)
at Object.readFileSync (fs.js:377:35)
at new LibraryEngine (/home/nic/Code/rpphub/workspaces/db/lib/runtime/index.js:36078:40)
at PrismaClient.getEngine (/home/nic/Code/rpphub/workspaces/db/lib/runtime/index.js:39108:16)
at new PrismaClient (/home/nic/Code/rpphub/workspaces/db/lib/runtime/index.js:39079:29) {
errno: -2,
syscall: 'open',
code: 'ENOENT',
path: '/home/nic/Code/rpphub/.git/schema.prisma',
clientVersion: '3.3.0'
}
***issue 2***:
the code fails runtime when being included in my Nextjs project in rpphub/workspaces/web
. at runtime, import * as PrismaClient from "@rpphub/db";
results in
error - Error: Cannot find module 'os'
at webpackEmptyContext (/home/nic/Code/rpphub/workspaces/web/.next/server/pages/api/test.js:53:10)
at ../../node_modules/.pnpm/supports-color@7.2.0/node_modules/supports-color/index.js (webpack-internal:///../db/lib/runtime/index.js:1738:15)
at __require2 (webpack-internal:///../db/lib/runtime/index.js:87:45)
at ../../node_modules/.pnpm/chalk@4.1.2/node_modules/chalk/source/index.js (webpack-internal:///../db/lib/runtime/index.js:2002:56)
at __require2 (webpack-internal:///../db/lib/runtime/index.js:87:45)
at eval (webpack-internal:///../db/lib/runtime/index.js:30776:33)
at Object.../db/lib/runtime/index.js (/home/nic/Code/rpphub/workspaces/web/.next/server/pages/api/test.js:42:1)
at __webpack_require__ (/home/nic/Code/rpphub/workspaces/web/.next/server/webpack-runtime.js:33:42)
at eval (webpack-internal:///../db/lib/index.js:17:5)
at Object.../db/lib/index.js (/home/nic/Code/rpphub/workspaces/web/.next/server/pages/api/test.js:32:1) {
code: 'MODULE_NOT_FOUND'
which you can see stems from var os2 = __require("os");
in rpphub/workspaces/db/lib/runtime/index.js.
. i recognize this could definitely be more of a next-question than a prisma question, if that's the case i apologize! i thought next might require further module transpilation but i had no luck going that route.
thank you all!Jason Abbott
10/21/2021, 7:57 PMNic Luciano
10/21/2021, 8:40 PM