Add following line to the end of the
bundle install after adding a new gem to
Execute the following commands in the terminal and we will see components folder being created in the
1bundle exec rails webpacker:install # enter n when prompted
In the above command, enter
n (no) when prompted and continue with the rest of its execution. This should be done so as to not override the existing
config/webpacker.yml file that was generated when we setup the project.
1bundle exec rails webpacker:install:react 2bundle exec rails generate react:install
We have successfully added React.js support to our application.
Before committing let's remove the unwanted files which were generated after running above commands:
Also remove the redeclaration of
components as argument from
application.js, if exists.
Now let's commit the changes:
npm install command would add
package-lock.json which isn't required as we are using Yarn. Thus avoid using
npm install. If executed then please don't commit
package-lock.json file. Add
package-lock.json to the
.gitignore file. Use
yarn add for installing new packages.
1git add -A 2git commit -m "Added React.js to the project"