remix icon indicating copy to clipboard operation
remix copied to clipboard

Unexpected Server Error with JavaScript

Open tempcoderr opened this issue 3 years ago • 8 comments
trafficstars

What version of Remix are you using?

1.7.4

Steps to Reproduce

I created a Remix app using the npx create-remix@latest command and then choosing Just the basics and then Remix App Server and then JavaScript, But when I then run the server it gives me the following error:

Unexpected Server Error

TypeError: isbot is not a function

If instead of Javascript I choose Typescript, the app works fine.

Expected Behavior

The app should load and run.

Actual Behavior

Gives an Unexpected Server Error error.

tempcoderr avatar Nov 01 '22 04:11 tempcoderr

Hi @tempcoderr, I could not reproduce the issue, see complete installation log below. isbot is used in app/entry.server.jsx and is listed as a dependency in package.json

Did you run npm install ?

🍺  ~ $ npx create-remix@latest
Need to install the following packages:
  create-remix@latest
Ok to proceed? (y) y
npm WARN deprecated @types/[email protected]: This is a stub types definition. keyv provides its own type definitions, so you do not need this installed.
? Where would you like to create your app? bug-4467
? What type of app do you want to create? Just the basics
? Where do you want to deploy? Choose Remix App Server if you're unsure; it's easy to change deployment targets. Remix App Server
? TypeScript or JavaScript? JavaScript
? Do you want me to run `npm install`? Yes
⠏ Creating your app…⠋ Migrating template to JavaScript…Processing 1 files...
Spawning 1 workers...
Sending 1 files to free worker...
⠴ Migrating template to JavaScript… SKIP /Users/didou/bug-4467/remix.env.d.ts
All done.
Results:
0 errors
0 unmodified
1 skipped
0 ok
Time elapsed: 0.387seconds
npm WARN deprecated @types/[email protected]: This is a stub types definition. keyv provides its own type definitions, so you do not need this installed.
npm WARN deprecated [email protected]: See https://github.com/lydell/source-map-url#deprecated
npm WARN deprecated [email protected]: Please see https://github.com/lydell/urix#deprecated
npm WARN deprecated [email protected]: https://github.com/lydell/resolve-url#deprecated
npm WARN deprecated [email protected]: This package has been deprecated and is no longer maintained. Please use @rollup/plugin-inject.
npm WARN deprecated [email protected]: See https://github.com/lydell/source-map-resolve#deprecated

added 1041 packages, and audited 1042 packages in 1m

224 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities
💿 That's it! `cd` into "/Users/didou/bug-4467" and check the README for development and deploy instructions!
🍺  ~ $ cd bug-4467/
🍺  ~/bug-4467 $ npm run dev

> dev
> remix dev

Watching Remix app in development mode...
💿 Built in 156ms
Remix App Server started at http://localhost:3002 (http://192.168.1.6:3002)
GET / 200 - - 28.032 ms

machour avatar Nov 01 '22 08:11 machour

I created a new Remix app and the issue still persists. Here is the process which I followed:

$ npx create-remix@latest new
? What type of app do you want to create? Just the basics
? Where do you want to deploy? Choose Remix App Server if you're unsure; it's easy to change deployment targets. Remix
App Server
? TypeScript or JavaScript? JavaScript
? Do you want me to run `npm install`? Yes
⠙ Migrating template to JavaScript…Processing 5 files...
Spawning 5 workers...
Sending 1 files to free worker...
Sending 1 files to free worker...
Sending 1 files to free worker...
Sending 1 files to free worker...
Sending 1 files to free worker...
⠼ Migrating template to JavaScript… SKIP D:/Projects/Remix Temp/new/remix.env.d.ts
 OKK D:/Projects/Remix Temp/new/app/entry.client.tsx
 OKK D:/Projects/Remix Temp/new/app/root.tsx
 OKK D:/Projects/Remix Temp/new/app/routes/index.tsx
 OKK D:/Projects/Remix Temp/new/app/entry.server.tsx
All done.
Results:
0 errors
0 unmodified
1 skipped
4 ok
Time elapsed: 2.203seconds
npm WARN deprecated @types/[email protected]: This is a stub types definition. keyv provides its own type definitions, so you do not need this installed.
npm WARN deprecated [email protected]: See https://github.com/lydell/source-map-url#deprecated
npm WARN deprecated [email protected]: Please see https://github.com/lydell/urix#deprecated
npm WARN deprecated [email protected]: This package has been deprecated and is no longer maintained. Please use @rollup/plugin-inject.
npm WARN deprecated [email protected]: See https://github.com/lydell/source-map-resolve#deprecated
npm WARN deprecated [email protected]: https://github.com/lydell/resolve-url#deprecated

added 1040 packages, and audited 1041 packages in 2m

224 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities
💿 That's it! `cd` into "D:\Projects\Remix Temp\new" and check the README for development and deploy instructions!

And now when I run the app, I get the error.

$ npm run dev

> dev
> remix dev

Watching Remix app in development mode...
💿 Built in 613ms
Remix App Server started at http://localhost:3000 (http://192.168.1.24:3000)
TypeError: isbot is not a function
    at handleRequest (D:\Projects\Remix Temp\new\app\entry.server.jsx:19:10)
    at handleDocumentRequest (D:\Projects\Remix Temp\new\node_modules\@remix-run\server-runtime\dist\server.js:431:20)
    at requestHandler (D:\Projects\Remix Temp\new\node_modules\@remix-run\server-runtime\dist\server.js:72:18)
    at D:\Projects\Remix Temp\new\node_modules\@remix-run\express\dist\server.js:39:22
GET / 500 - - 99.882 ms

tempcoderr avatar Nov 02 '22 04:11 tempcoderr

Could you check if you have isbot in your node_modules? What version got installed? What does console.log(isbot) right after its import in server entry yields?

machour avatar Nov 02 '22 06:11 machour

There is an isbot folder in the node_modules folder, and its version is 3.6.2. When I write the following statement,

const isbot = require("isbot").default;
console.log("isbot", isbot);

It returns isbot undefined.

tempcoderr avatar Nov 03 '22 04:11 tempcoderr

And what about:

const isbot = require("isbot");
console.log("isbot", isbot)

Also, what node version are you running? 🙏

machour avatar Nov 03 '22 07:11 machour

@machour Thanks for the reply. After changing const isbot = require("isbot").default; to const isbot = require("isbot");, the app has started and is working fine, and the value of isbot becomes isbot [Function: isbot].

tempcoderr avatar Nov 03 '22 09:11 tempcoderr

Thank you for the feedback 🙌🏼

@MichaelDeBoey do you know what might be going wrong with the TS => JS conversion here?

machour avatar Nov 03 '22 09:11 machour

I also face this issue today.

Remix Version: 1.7.5 Node Version: v18.12.0

Changing const isbot = require("isbot").default to const isbot = require("isbot") fixed the issue.

aayushbisen avatar Nov 09 '22 17:11 aayushbisen

I also face this issue today.

Remix Version: 1.7.5 Node Version: v18.12.0

Changing const isbot = require("isbot").default to const isbot = require("isbot") fixed the issue.

Can confirm similar behaviour.

Remix v. 1.7.5

Node version 16.13.1

Selected "Just the basics", "Remix Server", "Javascript". As soon as I changed the isbot require, the server automatically re-rendered index.jsx and it was displayed properly in the browser.

PhilipHassialis avatar Nov 13 '22 15:11 PhilipHassialis

I can confirm the same behavior is happening when choosing "Just the Basics" with "Remix Server" and "JavaScript". Remove the '.default;' from 'entry.server.jsx' on the 'const isbot = require("isbot")' line solves the problem.

cbenjamin2009 avatar Nov 14 '22 16:11 cbenjamin2009

when i open the console i see the following error react-dom.development.js:86 Warning: Extra attributes from the server: class at body at html at App at RemixRoute (http://localhost:3000/build/_shared/chunk-E37CJJXI.js:2653:3) at Routes2 (http://localhost:3000/build/_shared/chunk-E37CJJXI.js:2637:7) at Router (http://localhost:3000/build/_shared/chunk-E37CJJXI.js:725:15) at RemixCatchBoundary (http://localhost:3000/build/_shared/chunk-E37CJJXI.js:1056:10) at RemixErrorBoundary (http://localhost:3000/build/_shared/chunk-E37CJJXI.js:1097:9) at RemixEntry (http://localhost:3000/build/_shared/chunk-E37CJJXI.js:2531:12) at RemixBrowser (http://localhost:3000/build/_shared/chunk-E37CJJXI.js:3389:27)

sannamalai176 avatar Nov 18 '22 04:11 sannamalai176

@sannamalai176 this seems like another problem. Can you open a new discussion (Q&A category) please? 🙏🏼

machour avatar Nov 18 '22 08:11 machour

I have the same issue, I don't even know where the error is coming from, and all my loader return valid data with json() image

ghost avatar Nov 19 '22 10:11 ghost

@moutafatin1 Your error message have nothing to do with this issue. Please open a new question in the Discussions tab.

machour avatar Nov 19 '22 10:11 machour

I can confirm the same behavior is happening when choosing "Just the Basics" with "Remix Server" and "JavaScript". Remove the '.default;' from 'entry.server.jsx' on the 'const isbot = require("isbot")' line solves the problem.

+1 this is still happening with these exact options.

alexnguyennz avatar Nov 27 '22 01:11 alexnguyennz

We were able to narrow down this issue to be related to some weirdness with jscodeshift in certain environments in this thread: https://discord.com/channels/770287896669978684/1046094365426208818

xHomu avatar Nov 28 '22 19:11 xHomu

jscodeshift was removed as a dependency a couple version ago and this is no longer reproducible on recent versions (e.g. 1.19.2).

pcattori avatar Aug 04 '23 19:08 pcattori