remix
remix copied to clipboard
`remix dev` & `remix build` don't detect local packages from `pnpm` workspace
What version of Remix are you using?
1.6.7
Steps to Reproduce
- Clone the repo https://github.com/supachaidev/remix-build-cannot-find-module-repo.
- Run
pnpm i
. - Run
pnpm dev
orpnpm build
to see the warning message below in Terminal.
The path "shared-ui" is imported in app/routes/index.tsx but "shared-ui" was not found in your node_modules. Did you forget to install it?
Expected Behavior
The suggesting forget to install it?
message should not be present, because there is a symlink to the shared-ui
local package in node_modules
directory.
Actual Behavior
There is a warning message below when running remix dev
or remix build
.
The path "shared-ui" is imported in app/routes/index.tsx but "shared-ui" was not found in your node_modules. Did you forget to install it?
Same message with npm
workspaces. But application seems to work anyways. (also on Remix 1.6.7, and Windows 10)
Only when I add these lines to the shared component:
"exports": {
".": {
"import": "./dist/main.js"
}
},
Adding the require
or default
import clears the error/warning again:
"exports": {
".": {
"import": "./dist/main.js",
"default": "./dist/main.js"
}
},
Having the same issue while using pnpm workspaces
I have a similar issue with yarn link
. It seems like Remix is just not respecting symlinks in general?
Using pnpm. I'm seeing something slightly different, but related, in dev mode when I load the page:
Warning: You may have a dependency that could be inaccessible in production
| Please run: npm i .pnpm
Seems related to https://github.com/remix-run/remix/issues/4234
Its definetly symlink related
Update:
Okay its not symlink related
See solution on https://github.com/remix-run/remix/issues/4234#issuecomment-1317549172
You need to specify local packages to be bundled explicitily otherwise remix will assume all files that don't start with ./
or /
to be external
@supachaidev Please try @dan-cooke's solution and tell us if that was indeed the problem.
@machour, no @dan-cooke's solution does not silence the warning. I forked @supachaidev's example, upgraded all the Remix packages, and set serverDependenciesToBundle
to "all"
. Still seeing the warning when I do this:
(cd apps/my-remix-app && npx remix build)
Repo: https://github.com/stevecaldwell77/remix-build-cannot-find-module-repo
OK I think i figured out what's going on here. I noticed that I got the warning when I ran this:
npx remix build
But not if I ran it through my package.json's scripts using pnpm, i.e.:
pnpm run build
From looking at serverBareModulesPlugin.js
, it's checking the npm_config_user_agent
envar to decide whether to warn or not. If you use pnpm run
it will set that envar to something that causes the code to skip the warning.
This all seems pretty fragile to me. For my purpose, I'm using the Rush monorepo tool, so I'm doing something like:
rushx build
This is resulting in npm_config_user_agent
not being set, so I'm getting the warning, which Rush then treats as a broken build.
I'm hacking it by putting "pnpm run" inside my package.json scripts e.g.
"scripts: {
"build": "pnpm run build:remix && ...",
}
Using pnpm. I'm seeing something slightly different, but related, in dev mode when I load the page:
Warning: You may have a dependency that could be inaccessible in production | Please run: npm i .pnpm
@R-Bower did you solve this?
Any update on solving this issue in local development? It works but the console errors can cause confusion
I'm having the same issue in a project using yarn workspaces. If @remix-run/dev is hoisted into the workspace root it warns about importing a package that isn't hoisted. The project builds and runs fine but the console warning is confusing.
Repo: https://github.com/danphilibin/remix-yarn-workspaces-import
No longer reproducible in Remix @2.0.0-pre.5
.
I cloned the repro, replaced the existing apps/my-remix-app
via:
npx create-remix@pre --template https://github.com/remix-run/remix/tree/release-next/templates/remix
Then upgraded all the Remix packages:
pnpm i @remix-run/node@pre @remix-run/react@pre @remix-run/serve@pre @remix-run/dev@pre @remix-run/eslint-config@pre
Finally I added shared-ui
as a workspace dep to the app, ran pnpm i
and pnpm dev
.