Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

yarn rw dev only seems to work on Mac #475

Closed
ryancwalsh opened this issue Apr 25, 2020 · 8 comments
Closed

yarn rw dev only seems to work on Mac #475

ryancwalsh opened this issue Apr 25, 2020 · 8 comments

Comments

@ryancwalsh
Copy link
Contributor

After downgrading my Node, I'm able to get yarn create redwood-app ./redwoodblog to work.

But unfortunately another early step in the tutorial is not working for me: yarn rw dev. I've tried in 3 different environments:

On Windows 10 PowerShell as Admin:

PS C:\code\redwoodblog> yarn rw dev
yarn run v1.22.4
$ C:\code\redwoodblog\node_modules\.bin\rw dev
'C:\code\redwoodblog\node_modules\.bin\rw' is not recognized as an internal or external command,
operable program or batch file.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
PS C:\code\redwoodblog> yarn redwood dev
yarn run v1.22.4
$ C:\code\redwoodblog\node_modules\.bin\redwood dev
'C:\code\redwoodblog\node_modules\.bin\redwood' is not recognized as an internal or external command,
operable program or batch file.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

In Homestead Vagrant Ubuntu VirtualBox VM (on Win 10 host), the command does not error:

vagrant@vboxHomestead:~/Code/redwoodblog$ yarn rw dev
yarn run v1.22.4
$ /home/vagrant/Code/redwoodblog/node_modules/.bin/rw dev
$ /home/vagrant/Code/redwoodblog/node_modules/.bin/dev-server
$ /home/vagrant/Code/redwoodblog/node_modules/.bin/webpack-dev-server --config ../node_modules/@redwoodjs/core/config/webpack.development.js
19:44:36  db | $ /home/vagrant/Code/redwoodblog/node_modules/.bin/prisma generate --watch
19:44:40  db |
19:44:40  db | Watching... /home/vagrant/Code/redwoodblog/api/prisma/schema.prisma
19:44:40  db |
19:44:40  db | ✔ Generated Prisma Client to ./../node_modules/@prisma/client in 128ms
19:44:40  db |
19:44:43 web | ℹ 「wds」: Project is running at http://localhost:8910/
19:44:43 web | ℹ 「wds」: webpack output is served from /
19:44:43 web | ℹ 「wds」: Content not from webpack is served from /home/vagrant/Code/redwoodblog/web
19:44:43 web | ℹ 「wds」: 404s will fallback to /index.html
19:44:43 api | Listening on http://localhost:8911
19:44:43 api | Watching /home/vagrant/Code/redwoodblog/api
19:44:43 api |
19:44:43 api | Now serving
19:44:43 api |
19:44:43 api | ► http://localhost:8911/graphql/

But it does not open the browser on my host machine, and if I manually open the browser and visit http://localhost:8910/, I see:

This site can’t be reached
The webpage at http://localhost:8910/ might be temporarily down or it may have moved permanently to a new web address.

However, http://localhost:8911/graphql loads fine, which means port forwarding is working. So I don't know what the problem is.

I've also tried changing the port in redwood.toml in case there might have been conflicts, but it didn't help.

On MacOS 10.14.6, yarn rw dev works as expected (opens the browser to the appropriate page and shows the default page). But I'd love not to have to buy a Mac to use Redwood.

Can you see anything I'm doing wrong? Thanks.

P.S. I tried yarn upgrade because of #474 but it didn't help.

@ryancwalsh ryancwalsh changed the title yarn rw dev only seems to work on MAc yarn rw dev only seems to work on Mac Apr 25, 2020
@ryancwalsh
Copy link
Contributor Author

In my Vagrant VM, I see:

vagrant@vboxHomestead:~/Code/redwoodblog$ netstat -ant
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State
tcp        0      0 127.0.0.53:53           0.0.0.0:*               LISTEN
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN
tcp        0      0 0.0.0.0:5432            0.0.0.0:*               LISTEN
tcp        0      0 0.0.0.0:25              0.0.0.0:*               LISTEN
tcp        0      0 0.0.0.0:443             0.0.0.0:*               LISTEN
tcp        0      0 127.0.0.1:11300         0.0.0.0:*               LISTEN
tcp        0      0 0.0.0.0:3306            0.0.0.0:*               LISTEN
tcp        0      0 127.0.0.1:11211         0.0.0.0:*               LISTEN
tcp        0      0 127.0.0.1:6379          0.0.0.0:*               LISTEN
tcp        0      0 127.0.0.1:8910          0.0.0.0:*               LISTEN
tcp        0      0 0.0.0.0:111             0.0.0.0:*               LISTEN
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN
tcp        0      0 10.0.2.15:22            10.0.2.2:58686          ESTABLISHED
tcp        0      0 10.0.2.15:22            10.0.2.2:64775          ESTABLISHED
tcp        0      0 127.0.0.1:3306          127.0.0.1:60168         TIME_WAIT
tcp6       0      0 :::22                   :::*                    LISTEN
tcp6       0      0 :::5432                 :::*                    LISTEN
tcp6       0      0 :::25                   :::*                    LISTEN
tcp6       0      0 :::8025                 :::*                    LISTEN
tcp6       0      0 :::1025                 :::*                    LISTEN
tcp6       0      0 ::1:6379                :::*                    LISTEN
tcp6       0      0 :::8911                 :::*                    LISTEN
tcp6       0      0 :::111                  :::*                    LISTEN

I haven't figured out yet whether that looks good or not or what the problem is. It's strange to me that http://localhost:8911/graphql loads fine in my Win 10 (host) browser but http://localhost:8910/ does not.

@ryancwalsh
Copy link
Contributor Author

Because of 65377da (which I found at #216 (comment)), I added host = '0.0.0.0' to both the web and api sections of redwood.toml and then ran yarn rw dev.

But when I browsed to http://0.0.0.0:8910/ and http://0.0.0.0:8911/graphql, neither loaded.

I will keep searching other issues and forums trying to figure this out. I'd appreciate any tips if you have a moment. Thanks.

@ryancwalsh
Copy link
Contributor Author

In redwood.toml, I commented out host = '0.0.0.0' in api but left it in web.

In my Ubuntu VM, I ran ip addr and saw 3 entries, and the third mentioned inet 192.168.10.10/24.

So I ran yarn rw dev, and now http://192.168.10.10:8910/about works (instead of http://localhost:8910/ or http://0.0.0.0:8910/), and http://localhost:8911/graphql works too!

I don't fully understand this, but I'm happy that I can continue with the tutorial.

@ryancwalsh
Copy link
Contributor Author

host = '192.168.10.10' in web also allows http://192.168.10.10:8910/ to load in my browser.

But now my problem is that hot reloading doesn't work (in either case).

Editing BlogPostsCell.js (https://redwoodjs.com/tutorial/cells) has no effect until I cancel the process in the terminal and run yarn rw dev again.

Hot reloading is obviously a must. So I still haven't figured out how to set up my environment properly.

@thedavidprice
Copy link
Contributor

@ryancwalsh I'm excited about your persistence here! But bummed you keep running into errors. Nice work figuring out the IP/Ports for Vagrant.

Unfortunately, I was not able to duplicate the error with yarn rw dev on Windows 10 Powershell. I was able to successfully install a new Redwood App at v0.6.0 and then run yarn rw dev.

The error you're hitting, C:\code\redwoodblog\node_modules\.bin\rw' is not recognized as an internal or external command, operable program or batch file. seems to indicate an issue with the executables from your node packages either not being installed or not having correct permissions. I know you've already downgraded Node. Maybe you could try uninstalling and re-installing Yarn as well?

But before you do that, try deleting the node_modules/ directory entirely and then re-install with yarn install. If you have run git init, one way to do this is to use git clean -fxd in your App's root directory. Note: this will revert any changed files that have not been committed via git... you can lose changed-file progress. So proceed with caution.

I think you're going to continue to run into challenges with the Vagrant setup. If Powershell isn't working, could you either try GitBash or Bash on Windows?

@peterp
Copy link
Contributor

peterp commented Apr 26, 2020

@ryancwalsh I think virtualbox has an issue with watching files, you could try modifying the webpack configuration and setting it to poll:

https://redwoodjs.com/guides/webpack-config & https://webpack.js.org/configuration/watch/#watchoptions

@ryancwalsh
Copy link
Contributor Author

@thedavidprice @peterp Thank you so much for your quick responses. Very encouraging!

This did not seem to have any effect (when running via Vagrant):

module.exports = (config, { env }) => {
  if (env === 'development') {
    // Add dev plugin
    module.exports.watchOptions = {
      //https://github.com/redwoodjs/redwood/issues/475#issuecomment-619498123 and https://redwoodjs.com/guides/webpack-config
      poll: 1000, // Check for changes every second https://webpack.js.org/configuration/watch/#watchoptionspoll
      aggregateTimeout: 600, // https://webpack.js.org/configuration/watch/#watchoptionsaggregatetimeout
      ignored: [
        'node_modules/**',
        'api/node_modules/**',
        'web/node_modules/**',
      ],
    }
  }

  return config
}

And then I noticed https://webpack.js.org/configuration/watch/#watchoptionspoll says:

If watching does not work for you, try out this option. Watching does not work with NFS and machines in VirtualBox.

So I guess it's not expected to work since I was using VirtualBox.

In Git Bash (instead of VirtualBox), I ran npm install -g yarn and then:

$ yarn rw dev
yarn run v1.22.4
$ C:\code\redwoodblog\node_modules\.bin\rw dev
'C:\code\redwoodblog\node_modules\.bin\rw' is not recognized as an internal or external command,
operable program or batch file.
error Command failed with exit code 1.

Which looks like the problem I had in PowerShell. So then I figured you were probably right about node_modules being messed up, so I removed that folder and ran yarn install, which succeeded but with warnings:

[3/5] Fetching packages...
info fsevents@1.2.12: The platform "win32" is incompatible with this module.
info "fsevents@1.2.12" is an optional dependency and failed compatibility check. Excluding it from installation.
info fsevents@2.1.3: The platform "win32" is incompatible with this module.
info "fsevents@2.1.3" is an optional dependency and failed compatibility check. Excluding it from installation.
[4/5] Linking dependencies...
warning "@redwoodjs/core > @testing-library/react@10.0.3" has unmet peer dependency "react@*".
warning "@redwoodjs/core > @testing-library/react@10.0.3" has unmet peer dependency "react-dom@*".
[5/5] Building fresh packages...
success Saved lockfile.
Done in 112.65s.

Then I run:

$ yarn rw dev
yarn run v1.22.4
$ C:\code\redwoodblog\node_modules\.bin\rw dev
Generating the Prisma client... [started]
Generating the Prisma client... [completed]
09:40:31  db | $ C:\code\redwoodblog\node_modules\.bin\prisma generate --watch
09:40:31 web | $ C:\code\redwoodblog\node_modules\.bin\webpack-dev-server --config ../node_modules/@redwoodjs/core/config/webpack.development.js
09:40:31 api | $ C:\code\redwoodblog\node_modules\.bin\dev-server
09:40:32  db |
09:40:32  db | Watching... C:\code\redwoodblog\api\prisma\schema.prisma
09:40:32  db |
09:40:32  db | ✔ Generated Prisma Client to .\..\node_modules\@prisma\client in 175ms
09:40:32  db |
09:40:38 web | events.js:287
09:40:38 web |       throw er; // Unhandled 'error' event
09:40:38 web |       ^
09:40:38 web |
09:40:38 web | Error: listen EADDRINUSE: address already in use 0.0.0.0:8910
09:40:38 web |     at Server.setupListenHandle [as _listen2] (net.js:1313:16)
09:40:38 web |     at listenInCluster (net.js:1361:12)
09:40:38 web |     at doListen (net.js:1500:7)
09:40:38 web |     at processTicksAndRejections (internal/process/task_queues.js:85:21)
09:40:38 web | Emitted 'error' event on Server instance at:
09:40:38 web |     at emitErrorNT (net.js:1340:8)
09:40:38 web |     at processTicksAndRejections (internal/process/task_queues.js:84:21) {
09:40:38 web |   code: 'EADDRINUSE',
09:40:38 web |   errno: 'EADDRINUSE',
09:40:38 web |   syscall: 'listen',
09:40:38 web |   address: '0.0.0.0',
09:40:38 web |   port: 8910
09:40:38 web | }
09:40:38 web | error Command failed with exit code 1.
09:40:38 web | info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
09:40:38 web | cd C:\code\redwoodblog\web && yarn webpack-dev-server --config ../node_modules/@redwoodjs/core/config/webpack.development.js exited with code 1
09:40:38 web | cd C:\code\redwoodblog\web && yarn webpack-dev-server --config ../node_modules/@redwoodjs/core/config/webpack.development.js restarted
09:40:38 web | $ C:\code\redwoodblog\node_modules\.bin\webpack-dev-server --config ../node_modules/@redwoodjs/core/config/webpack.development.js
09:40:40 web | events.js:287
09:40:40 web |       throw er; // Unhandled 'error' event
09:40:40 web |       ^
09:40:40 web |
09:40:40 web | Error: listen EADDRINUSE: address already in use 0.0.0.0:8910
09:40:40 web |     at Server.setupListenHandle [as _listen2] (net.js:1313:16)
09:40:40 web |     at listenInCluster (net.js:1361:12)
09:40:40 web |     at doListen (net.js:1500:7)
09:40:40 web |     at processTicksAndRejections (internal/process/task_queues.js:85:21)
09:40:40 web | Emitted 'error' event on Server instance at:
09:40:40 web |     at emitErrorNT (net.js:1340:8)
09:40:40 web |     at processTicksAndRejections (internal/process/task_queues.js:84:21) {
09:40:40 web |   code: 'EADDRINUSE',
09:40:40 web |   errno: 'EADDRINUSE',
09:40:40 web |   syscall: 'listen',
09:40:40 web |   address: '0.0.0.0',
09:40:40 web |   port: 8910
09:40:40 web | }
09:40:40 web | error Command failed with exit code 1.
09:40:40 web | info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
09:40:40 web | cd C:\code\redwoodblog\web && yarn webpack-dev-server --config ../node_modules/@redwoodjs/core/config/webpack.development.js exited with code 1
09:40:40 web | cd C:\code\redwoodblog\web && yarn webpack-dev-server --config ../node_modules/@redwoodjs/core/config/webpack.development.js restarted
09:40:40 web | $ C:\code\redwoodblog\node_modules\.bin\webpack-dev-server --config ../node_modules/@redwoodjs/core/config/webpack.development.js
09:40:41 web | events.js:287
09:40:41 web |       throw er; // Unhandled 'error' event
09:40:41 web |       ^
09:40:41 web |
09:40:41 web | Error: listen EADDRINUSE: address already in use 0.0.0.0:8910
09:40:41 web |     at Server.setupListenHandle [as _listen2] (net.js:1313:16)
09:40:41 web |     at listenInCluster (net.js:1361:12)
09:40:41 web |     at doListen (net.js:1500:7)
09:40:41 web |     at processTicksAndRejections (internal/process/task_queues.js:85:21)
09:40:41 web | Emitted 'error' event on Server instance at:
09:40:41 web |     at emitErrorNT (net.js:1340:8)
09:40:41 web |     at processTicksAndRejections (internal/process/task_queues.js:84:21) {
09:40:41 web |   code: 'EADDRINUSE',
09:40:41 web |   errno: 'EADDRINUSE',
09:40:41 web |   syscall: 'listen',
09:40:41 web |   address: '0.0.0.0',
09:40:41 web |   port: 8910
09:40:41 web | }
09:40:41 web | error Command failed with exit code 1.
09:40:41 web | info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
09:40:41 web | cd C:\code\redwoodblog\web && yarn webpack-dev-server --config ../node_modules/@redwoodjs/core/config/webpack.development.js exited with code 1
09:40:41 web | cd C:\code\redwoodblog\web && yarn webpack-dev-server --config ../node_modules/@redwoodjs/core/config/webpack.development.js restarted
09:40:41 web | $ C:\code\redwoodblog\node_modules\.bin\webpack-dev-server --config ../node_modules/@redwoodjs/core/config/webpack.development.js
09:40:42 api | Listening on http://localhost:8911
09:40:42 api | Watching C:\code\redwoodblog\api
09:40:42 api |
09:40:42 api | Now serving
09:40:42 api |
09:40:42 api | ► http://localhost:8911/graphql/
09:40:43 web | events.js:287
09:40:43 web |       throw er; // Unhandled 'error' event
09:40:43 web |       ^
09:40:43 web |
09:40:43 web | Error: listen EADDRINUSE: address already in use 0.0.0.0:8910
09:40:43 web |     at Server.setupListenHandle [as _listen2] (net.js:1313:16)
09:40:43 web |     at listenInCluster (net.js:1361:12)
09:40:43 web |     at doListen (net.js:1500:7)
09:40:43 web |     at processTicksAndRejections (internal/process/task_queues.js:85:21)
09:40:43 web | Emitted 'error' event on Server instance at:
09:40:43 web |     at emitErrorNT (net.js:1340:8)
09:40:43 web |     at processTicksAndRejections (internal/process/task_queues.js:84:21) {
09:40:43 web |   code: 'EADDRINUSE',
09:40:43 web |   errno: 'EADDRINUSE',
09:40:43 web |   syscall: 'listen',
09:40:43 web |   address: '0.0.0.0',
09:40:43 web |   port: 8910
09:40:43 web | }
09:40:43 web | error Command failed with exit code 1.
09:40:43 web | info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
09:40:43 web | cd C:\code\redwoodblog\web && yarn webpack-dev-server --config ../node_modules/@redwoodjs/core/config/webpack.development.js exited with code 1

yarn config set ignore-engines true from yarnpkg/yarn#2051 (comment) did not help, so I changed it back to false.

Then I remembered to remove host = '0.0.0.0' from redwood.toml since I'm now running from Windows (Git Bash) rather than a VM.

yarn rw dev again, and it seemed to run fine, and now http://localhost:8910/ (instead of http://192.168.10.10:8910/) partially loads in Chrome, but the data doesn't come through ("Error: Network error: Unexpected token E in JSON at position 0"), and I see this in the Git Bash terminal:

09:42:03 api | ► http://localhost:8911/graphql/
09:42:08 web | [HPM] Error occurred while trying to proxy request /graphql from localhost:8910 to http://localhost:8911 (ECONNRESET) (https://nodejs.org/api/errors.html#errors_common_system_errors)

I will try restarting my Windows machine entirely.

@ryancwalsh
Copy link
Contributor Author

Hot reloading works after restarting Windows!

I guess I should have used straight Git Bash all along instead of Git Bash ssh into Vagrant.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants