remix: The package `remix` can't resolve `./client` and `./server` since v0.17.1

If you install the package remix to import things from there instead of all of @remix-run/* individual packages it throw an error because it can’t resolve ./client and ./server. This only happens with the v0.17.1 and v0.17.2, the version v0.17.0 works without issues.

> node_modules/remix/browser/index.js:2:14: error: Could not resolve "./client"
    2 │ export * from './client';
      ╵               ~~~~~~~~~~

 > node_modules/remix/browser/index.js:3:14: error: Could not resolve "./server"
    3 │ export * from './server';
      ╵               ~~~~~~~~~~

Error: Build failed with 2 errors:
node_modules/remix/browser/index.js:2:14: error: Could not resolve "./client"
node_modules/remix/browser/index.js:3:14: error: Could not resolve "./server"

I’m using the latest release of Node v14 and both npm (v7) and yarn (v1) to install the package and run the commands to build the app or run it in dev-mode.

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 21 (4 by maintainers)

Most upvoted comments

I noticed that Prisma uses the node_modules/.prisma folder instead of mutating the node_modules/prisma folder directly. Maybe we should be doing the same and modifying node_modules/.remix instead of node_modules/remix

The main thing we need to be sure of is that we can still treeshake the remix package no matter what we’re doing.

I am experiencing this error only with yarn. A yarn add breaks the install every time and then I have to run yarn upgrade to fix.

@mjackson I’m hopeful the .remix approach might solve the problem I’m having too. I am trying to use Remix with Rush + PNPM workspaces, but every time I run remix setup, it breaks builds of unrelated projects in the monorepo and I need to purge my pnpm cache and reinstall from the registry.

With PNPM, node_modules for a project is hardlinked back to a central store, and I suspect some of the magic of remix setup is affecting that store.

@3stacks d’oh, no you’re not missing anything, I failed to include the script we’re using, here it is:

./bin/remix-magic

#!/bin/bash
set -euo pipefail

# @remix-run/node and @remix-run/react have postinstall scripts that
# mutate the remix/browser package. Subsequent yarn commands will
# reset remix/browser.
#
# This script runs as a postinstall for our webapp project, so that
# remix has the chance to fix itself up after we yarn add things.
me=$(node -e 'console.log(require("path").resolve(process.argv[1]))' "$0")
here=$(dirname "${me}")

node "${here}"/../node_modules/@remix-run/node/scripts/postinstall.js
node "${here}"/../node_modules/@remix-run/react/scripts/postinstall.js

Closing this now as our approach moving forward will be to use direct imports from the remix scoped package instead of the core module.

@alexblack That works beautifully! I removed patch-package because I don’t need it, but the setup was easy

Had to also chmod +x ./bin/remix-magic.

package.json

"scripts": {
  "postinstall": "./bin/remix-magic"
}

Thanks for that, that’ll serve nicely until an official solution comes

We’re using remix successfully with yarn after facing this error by including this in our package.json:

"postinstall": "./bin/remix-magic && patch-package",

As @tchak said, it happens when running a yarn add. yarn upgrade doesn’t work for me for some reason so I have to rm -rf node_modules and run a yarn install again and it works.