GithubHelp home page GithubHelp logo

bookofgreg / react-rails-example-app Goto Github PK

View Code? Open in Web Editor NEW
91.0 3.0 48.0 973 KB

Minimal basic demonstration React-Rails sample application using Webpacker

License: MIT License

Ruby 69.90% JavaScript 8.90% CSS 2.18% HTML 17.82% CoffeeScript 0.65% SCSS 0.55%
react-rails webpack-es6 sprockets

react-rails-example-app's Introduction

React-Rails Demo Application

This repo is an example of a simple working Rails 5, Webpack(er)3, React-Rails 2.3+ application.

Where generators are used, the git commit will be the command ran to get to the current application state so it will hopefully be easy to follow along at home.

How to test the Demo Application

1) Install the JS packages:

$ yarn install # or npm install

2) Install GEM packages:

$ bundle install

3) In one terminal run the rails server:

$ rails s

4) In another terminal run the webpack server:

$ ./bin/webpack-dev-server

5) Visit the welcome page

http://localhost:3000/welcome/index

Branches

This repo contains two trees, one Webpacker and one Sprockets.

Each branch illustrates a react-rails ability.

react-rails-example-app's People

Contributors

bookofgreg avatar cristofer avatar dependabot[bot] avatar josephmarkus avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

react-rails-example-app's Issues

./bin/webpack-dev-server fails with Error: Cannot find module 'webpack-cli/bin/config-yargs'

39e7c56

npm install
rails s

Seems fine, on other shell:

./bin/webpack-dev-server

fails with:

The CLI moved into a separate package: webpack-cli
Please install 'webpack-cli' in addition to webpack itself to use the CLI
-> When using npm: npm i -D webpack-cli
-> When using yarn: yarn add -D webpack-cli
internal/modules/cjs/loader.js:883
  throw err;
  ^

Error: Cannot find module 'webpack-cli/bin/config-yargs'
Require stack:
- /home/ciro/git/react-rails-example-app/node_modules/webpack-dev-server/bin/webpack-dev-server.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15)
    at Function.Module._load (internal/modules/cjs/loader.js:725:27)
    at Module.require (internal/modules/cjs/loader.js:952:19)
    at require (internal/modules/cjs/helpers.js:88:18)
    at Object.<anonymous> (/home/ciro/git/react-rails-example-app/node_modules/webpack-dev-server/bin/webpack-dev-server.js:65:1)
    at Module._compile (internal/modules/cjs/loader.js:1063:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
    at Module.load (internal/modules/cjs/loader.js:928:32)
    at Function.Module._load (internal/modules/cjs/loader.js:769:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/home/ciro/git/react-rails-example-app/node_modules/webpack-dev-server/bin/webpack-dev-server.js'
  ]
}

OK, I run:

npm i -D webpack-cli
./bin/webpack-dev-server

but problem persists:

internal/modules/cjs/loader.js:883
  throw err;
  ^

Error: Cannot find module 'webpack-cli/bin/config-yargs'
Require stack:
- /home/ciro/git/react-rails-example-app/node_modules/webpack-dev-server/bin/webpack-dev-server.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15)
    at Function.Module._load (internal/modules/cjs/loader.js:725:27)
    at Module.require (internal/modules/cjs/loader.js:952:19)
    at require (internal/modules/cjs/helpers.js:88:18)
    at Object.<anonymous> (/home/ciro/git/react-rails-example-app/node_modules/webpack-dev-server/bin/webpack-dev-server.js:65:1)
    at Module._compile (internal/modules/cjs/loader.js:1063:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
    at Module.load (internal/modules/cjs/loader.js:928:32)
    at Function.Module._load (internal/modules/cjs/loader.js:769:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/home/ciro/git/react-rails-example-app/node_modules/webpack-dev-server/bin/webpack-dev-server.js'
  ]
}

This is the relevant SO apparently: https://stackoverflow.com/questions/40379139/cannot-find-module-webpack-bin-config-yargs

I try:

./bin/webpack serve

but fails with:

ERROR in Entry module not found: Error: Can't resolve 'serve' in '/home/ciro/git/react-rails-example-app'

A bit more webpack knowledge or trial and error is needed :-)

Ubuntu 20.10, Ruby 2.7, node.js v14.16.0. You might also want to track the package-lock.json that currently gets generated by npm.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.