Skip to content

Commit

Permalink
fix: express peerDependency in templates
Browse files Browse the repository at this point in the history
@remix-run/dev has an optional peer dependency on express that is required for
using the `remix dev` command. This commit adds a devDependency on express to
every template using `remix dev` in its package.json.
  • Loading branch information
cmd-johnson committed Feb 22, 2022
1 parent d5bc99c commit 5c57e86
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 3 deletions.
3 changes: 3 additions & 0 deletions packages/create-remix/templates/fly/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,8 @@
"dependencies": {
"@remix-run/serve": "*",
"cross-env": "^7.0.3"
},
"devDependencies": {
"express": "^4.17.1"
}
}
3 changes: 3 additions & 0 deletions packages/create-remix/templates/remix/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,8 @@
"dependencies": {
"@remix-run/serve": "*",
"cross-env": "^7.0.3"
},
"devDependencies": {
"express": "^4.17.1"
}
}
3 changes: 2 additions & 1 deletion packages/create-remix/templates/vercel/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
},
"devDependencies": {
"@remix-run/serve": "*",
"cross-env": "^7.0.3"
"cross-env": "^7.0.3",
"express": "^4.17.1"
}
}
10 changes: 8 additions & 2 deletions packages/remix-dev/cli/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,16 +145,22 @@ export async function watch(
export async function dev(remixRoot: string, modeArg?: string) {
// TODO: Warn about the need to install @remix-run/serve if it isn't there?
let createApp: typeof createAppType;
let express: typeof Express;
try {
let serve = require("@remix-run/serve");
createApp = serve.createApp;
express = require("express");
} catch (err) {
throw new Error(
"Could not locate @remix-run/serve. Please verify you have it installed to use the dev command."
);
}
let express: typeof Express;
try {
express = require("express");
} catch (err) {
throw new Error(
"Could not locate express. Please verify you have it installed to use the dev command."
);
}

let config = await readConfig(remixRoot);
let mode = isBuildMode(modeArg) ? modeArg : BuildMode.Development;
Expand Down

0 comments on commit 5c57e86

Please sign in to comment.