0

I'm trying to setup my new project with Rails 5.1 and Wepacker-react, but I get first error very quickly. I have been created new component in javascript/packs The code is basic:

javascript/packs/home.jsx

import React from 'react'
import ReactDOM from 'react-dom'
import PropTypes from 'prop-types'

const Home = props => (
  <div>Hello {props.name}!</div>
)

Home.defaultProps = {
  name: ''
}

Home.propTypes = {
  name: PropTypes.string
}

document.addEventListener('DOMContentLoaded', () => {
  ReactDOM.render(
    <Home name="Daniel" />,
    document.body.appendChild(document.createElement('div')),
  )
})

Im rendering this component in index view:

index.html.erb

<%= javascript_pack_tag 'home' %>

But I got this error: MissingEntryError

I would to add that I had imported this component in app....js What is missing?

Daniel
  • 153
  • 2
  • 12
  • It's going to look in your manifest.json file to determing what it can load with `javascript_pack_tag`. What does your manifest.json look like? – AndrewKS Nov 13 '17 at 20:58

1 Answers1

0

I had similar error where I was getting the same error message.

Another error message related to MissingEntryError was:

Webpacker can't find react_file.js in /home/.../Workspaces/my-app/public/packs/manifest.json

The manifest.json file had not been created.

The problem was solve after I added some missed NPM packages, such as Webpack-dev-server and @rails/webpacker. All those missed packages were part of node_modules folder. I just had to install them to solve the problem.

Pedro Gabriel Lima
  • 1,122
  • 1
  • 9
  • 24