shanghuang
shanghuang2y ago

Could not resolve "convex/server"

convex/_generated/server.js:20:7:
20 │ } from "convex/server";
╵ ~~~~~~~~~~~~~~~

The Yarn Plug'n'Play manifest forbids importing "convex" here because
it's not listed as a dependency of this package:

../.pnp.cjs:45:33:
45 │ "packageDependencies": [
╵ ^

You can mark the path "convex/server" as external to exclude it from
the bundle, which will remove this error.
convex/_generated/server.js:20:7:
20 │ } from "convex/server";
╵ ~~~~~~~~~~~~~~~

The Yarn Plug'n'Play manifest forbids importing "convex" here because
it's not listed as a dependency of this package:

../.pnp.cjs:45:33:
45 │ "packageDependencies": [
╵ ^

You can mark the path "convex/server" as external to exclude it from
the bundle, which will remove this error.
I run this error while trying to create the "convex/tasks.ts" from the NextJS quickstart.
16 Replies
ballingt
ballingt2y ago
Hi @shanghuang, did you figure this out? It looks like you need to install convex. Since it looks like you're using yarn, I think what you want in yarn add convex
shanghuang
shanghuangOP2y ago
Hi Tom, thanks for you reply. I wan't able to figure this out yet. Yarn was not used in the project. I was following the quickstart guide for nextjs. using npm. I am sure the package is installed. I was able to
npx convex import tasks sampleData.jsonl
npx convex import tasks sampleData.jsonl
and sees the data on Convex dashboard. When it gets to preparing Convex functions.... for tasks.ts, it jumps up this erorr:
✔ 06:59:40 Convex functions ready! (1.02s)
⠇ Preparing Convex functions...
✘ [ERROR] Could not resolve "convex/server"

convex/_generated/server.js:20:7:
20 │ } from "convex/server";
╵ ~~~~~~~~~~~~~~~

The Yarn Plug'n'Play manifest forbids importing "convex" here because it's not listed as a
dependency of this package:

../.pnp.cjs:45:33:
45 │ "packageDependencies": [
╵ ^

You can mark the path "convex/server" as external to exclude it from the bundle, which will
remove this error.
✔ 06:59:40 Convex functions ready! (1.02s)
⠇ Preparing Convex functions...
✘ [ERROR] Could not resolve "convex/server"

convex/_generated/server.js:20:7:
20 │ } from "convex/server";
╵ ~~~~~~~~~~~~~~~

The Yarn Plug'n'Play manifest forbids importing "convex" here because it's not listed as a
dependency of this package:

../.pnp.cjs:45:33:
45 │ "packageDependencies": [
╵ ^

You can mark the path "convex/server" as external to exclude it from the bundle, which will
remove this error.
Here is the package.json
{
"name": "my-app",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint"
},
"dependencies": {
"@types/node": "20.5.9",
"@types/react": "18.2.21",
"@types/react-dom": "18.2.7",
"autoprefixer": "10.4.15",
"convex": "^1.2.1",
"eslint": "8.48.0",
"eslint-config-next": "13.4.19",
"next": "13.4.19",
"postcss": "8.4.29",
"react": "18.2.0",
"react-dom": "18.2.0",
"tailwindcss": "3.3.3",
"typescript": "5.2.2"
}
}
{
"name": "my-app",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint"
},
"dependencies": {
"@types/node": "20.5.9",
"@types/react": "18.2.21",
"@types/react-dom": "18.2.7",
"autoprefixer": "10.4.15",
"convex": "^1.2.1",
"eslint": "8.48.0",
"eslint-config-next": "13.4.19",
"next": "13.4.19",
"postcss": "8.4.29",
"react": "18.2.0",
"react-dom": "18.2.0",
"tailwindcss": "3.3.3",
"typescript": "5.2.2"
}
}
I am using npm 10.0.0 npx 10.0.0
ballingt
ballingt2y ago
Do you intend to be using yarn plug'n'play? The error makes it sound like you need to add convex to that file, ../.pnp.cjs
shanghuang
shanghuangOP2y ago
that's what i thought so. But I don't have yarn on my develop machine, and i can't find a .pnp.cjs on the machine. My guess is that it has somethign to do with the previous yarn I installed. But, at this moment, i can't spot the error. Hi Tom, after installing a clean version of MacOS, installed node through Brew. It still jumps up the same message.
jamwt
jamwt2y ago
@shanghuang what's the output of npm i
Michal Srb
Michal Srb2y ago
@shanghuang I'd make sure to start with a fresh project directory that never uses Yarn.
shanghuang
shanghuangOP2y ago
Hi @jamwt , the message after npm install convex, , and the message after npm i.
No description
No description
shanghuang
shanghuangOP2y ago
@Michal Srb I am pretty sure it's a fresh project and a fresh development machine. The operation system was just reset to factory default. Then used brew and npm to install a couple of required packages.
No description
No description
No description
jamwt
jamwt2y ago
@shanghuang can you rm -rf the convex/_generated folder and then just try npx convex codegen by itself?
Michal Srb
Michal Srb2y ago
Do you have .pnp.cjs in the project folder? ls -al to see all files. (if yes, delete it with rm .pnp.cjs)
shanghuang
shanghuangOP2y ago
Hi Michal, No, I don't have .pnp.cjs in the project folder.
shanghuang
shanghuangOP2y ago
Hey Jamie, Thanks for looking into this issue. I try to rm the _generate fold. But still, the issue raised.
No description
jamwt
jamwt2y ago
This appears to be triggered by a .pnp.cjs file in the parent directory… ~/Code
jamwt
jamwt2y ago
Stack Overflow
The Yarn Plug'n'Play manifest forbids importing "XYZ" here because ...
Yarn 3.5 (stable) using ViteJS - I keep getting this same error for various third party packages. I'm lost on how to properly solve this. The message says I can mark "react" as external, ...
shanghuang
shanghuangOP2y ago
Problem solved! Thanks @jamwt , and Thanks @Michal Srb as well. I should have checked the parent folder. I love the concept and idea behind convex, so wanna try it out and introduce to my friends !!
jamwt
jamwt2y ago
really glad to hear it!

Did you find this page helpful?