azar
azar12mo ago

npx convex dev error

getting error in this format
The package [PACKAGE_NAME] wasn't found on the file system but is built
into node. Are you trying to bundle for node? You can use "platform:
'node'" to do that, which will remove this error.
The package [PACKAGE_NAME] wasn't found on the file system but is built
into node. Are you trying to bundle for node? You can use "platform:
'node'" to do that, which will remove this error.
this is my first time using convex, i have looked other related post, but could nt be able to fix it, can you tell me where should i made the changes required ? project link - https://github.com/azr-arch/unishare --verbose logs:
Codegen finished.
Skipping convex\auth.config.ts that contains multiple dots
Preparing convex\auth.ts
Preparing convex\clerk.ts
Preparing convex\file.ts
Preparing convex\http.ts
Skipping convex\README.md
Skipping convex\schema.ts
Skipping convex\tsconfig.json
Preparing convex\users.ts
Skipping convex\_generated\api.d.ts
Skipping convex\_generated\api.js
Skipping convex\_generated\dataModel.d.ts
Skipping convex\_generated\server.d.ts
Skipping convex\_generated\server.js
⠹ Bundling modules for Convex's runtime...
X [ERROR] Could not resolve "fs"

node_modules/next/dist/compiled/gzip-size/index.js:1:2840:
1 │ ...trict";e.exports=require("fs")},781:e=>{"use strict";e...
╵ ~~~~

The package "fs" wasn't found on the file system but is built into
node. Are you trying to bundle for node? You can use "platform:
'node'" to do that, which will remove this error.
Codegen finished.
Skipping convex\auth.config.ts that contains multiple dots
Preparing convex\auth.ts
Preparing convex\clerk.ts
Preparing convex\file.ts
Preparing convex\http.ts
Skipping convex\README.md
Skipping convex\schema.ts
Skipping convex\tsconfig.json
Preparing convex\users.ts
Skipping convex\_generated\api.d.ts
Skipping convex\_generated\api.js
Skipping convex\_generated\dataModel.d.ts
Skipping convex\_generated\server.d.ts
Skipping convex\_generated\server.js
⠹ Bundling modules for Convex's runtime...
X [ERROR] Could not resolve "fs"

node_modules/next/dist/compiled/gzip-size/index.js:1:2840:
1 │ ...trict";e.exports=require("fs")},781:e=>{"use strict";e...
╵ ~~~~

The package "fs" wasn't found on the file system but is built into
node. Are you trying to bundle for node? You can use "platform:
'node'" to do that, which will remove this error.
GitHub
GitHub - azr-arch/unishare: UniShare is a platform that allows user...
UniShare is a platform that allows users to upload, host, and share documents, images, and videos. It's perfect for anyone who wants to share files quickly and easily online. - azr-arch/unishare
10 Replies
ballingt
ballingt12mo ago
@azar it sounds like you're trying to use a Node.js builtin (fs) which doesn't work in convex queries and mutations. See https://docs.convex.dev/functions/runtimes
Runtimes | Convex Developer Hub
Convex functions can run in two runtimes:
azar
azarOP12mo ago
i dont know where i am using it, can you take a look at provided repo, and tell me where the fix is required?
erquhart
erquhart12mo ago
Your error message says that next is using it, not sure what next functionality might be at play here. You could use the node runtime for whatever next functionality is being used and see if it works there.
azar
azarOP12mo ago
tried using "use node" on top of every file in convex, still it dont work
erquhart
erquhart12mo ago
Oh I just meant whatever file is importing from the next package, but it would have to not contain any queries or mutations Using node for all convex files will break any file that contains queries or mutations, and probably some others. Taking a look at your repo You have an auth.ts in your convex folder that is likely causing it, and I don’t believe you need it Your code is being indexed on GitHub so I can’t search it right now (on mobile) - where are you using the generateAuthToken() function from that file?
azar
azarOP12mo ago
did you mean getAuthToken ? in auth.ts looks like it isnt being used anywhere
erquhart
erquhart12mo ago
Right but is your convex/auth.ts file being imported anywhere
azar
azarOP12mo ago
i dont think so wait i am trying to run the convex server without auth file it worked! thanks man
erquhart
erquhart12mo ago
No problem!
azar
azarOP12mo ago
👍

Did you find this page helpful?