It looks like that ParcelJS can't find packages from the root node_modules folder in monorepo with Yarn workspaces.
├── node_modules (modules in this directory are not found)
└── app (with ParcelJS)
└── node_modules (parcel-bundler is in this folder)
It should solve modules from the root node_modules folder.
It tries to find directory in the app level but that directory is in the root folder of monorepo.

Support hoisting shared dependencies.
I want to build a monorepo with ParcelJS.
My environment:
Ok, it was something weird. After reinstall it suddenly works.
Had the exact same problem. After yarn again, it found the modules in the root
This seems still broken. I've run yarn install twice in a monorepo. My web app is in foo. yarn install creates foo/node_modules/.bin/parcel as a symlink to ../../../node_modules/parcel-bundler/bin/cli.js.
I'm running yarn run start in the foo workspace, which runs parcel index.html from foo/package.json. I get the following error:
Error: ENOENT: no such file or directory, open '/home/dandv/myapp/foo/node_modules/parcel-bundler/src/builtins/css-loader.js'
It's clear that Parcel looks for the src files in the foo directory, not in the monorepo's node_modules.
Running the CLI from the monorepo's node_modules fails as well:
~/myapp/foo$ ../node_modules/parcel-bundler/bin/cli.js index html
Server running at http://localhost:1234
🚨 No entries found.
at Bundler.bundle (/home/dandv/myapp/node_modules/parcel-bundler/src/Bundler.js:261:17)
../node_modules/.bin/parcel index.html fails with the same css-loader ENOENT error.
What else can I try?
Same problem here
But succeeded with using NODE_PATH set to root of mono repo. eg:
NODE_PATH=../../../../../../ parcel build ...
Same issue here.
File structure:
/node_modules/package-a@
/node_modules/parcel
/packages/package-a
/packages/demo
/packages/demo/package.js:
{
"name": "demo",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"scripts": {
"lint": "eslint src",
"start": "parcel src/index.html",
"build": "parcel build src/index.html"
},
"devDependencies": {
"@babel/core": "^7.3.4",
"parcel": "^1.11.0"
},
"dependencies": {
"preact": "^8.4.2",
"preact-leaflet": "1.0.0"
}
}
Full repo at https://github.com/kontrollanten/preact-leaflet/tree/workspaces
I was experiencing this problem because I was running parcel index.html from a global parcel installation. After I put that into the start script, and executed with yarn start, it worked.
NODE_PATH=../../ solved the problem for me in my Lerna monorepo
I came across this issue as well ~ I had parcel installed in one of my project directories, fixed this by removing it from the project and installing it in the root package.json. not ideal but it works!
I came across this issue as well ~ I had parcel installed in one of my project directories, fixed this by removing it from the project and installing it in the root package.json. not ideal but it works!
@good-idea Did you run Parcel from the root as well?
@good-idea's solution appears to work for me as well. I still run Parcel from the client folder.
Most helpful comment
Had the exact same problem. After
yarnagain, it found the modules in the root