0

I have tried everything in the book it feels, yet I keep getting the same error. Surprisingly, I have not found this exact error anywhere else.


remote:        error Couldn't find a package.json file in "/tmp/build_0e5b0c14c98db4a63ddfc87fc6d11490"

Here is the full error on Pastebin

Here is the repository for the (rather simple) blogger project

I even tried running rake assets:precompile locally and run into absolutely no errors. I ran RAILS_ENV=production bundle exec rake assets:precompile, pushed to my repo then tried to deploy, nothing.

I raked through tons of StackOverflow questions and tried googling my error, giving every edit/command I came across a try, but no luck.

EDIT: The following are the contents of my package.json file

{
  "name": "blogger",
  "private": true,
  "dependencies": {
    "@rails/actioncable": "^6.0.0",
    "@rails/activestorage": "^6.0.0",
    "@rails/ujs": "^6.0.0",
    "@rails/webpacker": "4.2.2",
    "turbolinks": "^5.2.0"
  },
  "version": "0.1.0",
  "devDependencies": {
    "webpack-dev-server": "^3.10.1"
  }
}
Eduardo06sp
  • 331
  • 1
  • 4
  • 16

2 Answers2

2

enter image description here

Basic configuration for Rails 6 :-

Run yarn install, or just yarn. It will create a package.json file :-

`package.json'

This file contain necessary packages for your webpack.

For more references read :-

#yarn docs

#webpacker

And also if you want to precompile in production environment change the config in below file :-

config/webpacker.yml

production:
  <<: *default

  # Production depends on precompilation of packs prior to booting for performance.
  compile:true ## just make this compile true

  # Extract and emit a css file
  extract_css: true

  # Cache manifest.json for performance
  cache_manifest: true

then execute commands :-

RAILS_ENV=production rake assets:clobber 
RAILS_ENV=production rake assets:precompile
code_aks
  • 1,972
  • 1
  • 12
  • 28
  • I followed your steps, but I already had a package.json file for my app. I updated my post to display its contents. It gives me the same exact error regardless. – Eduardo06sp Dec 28 '19 at 04:56
  • Thank you for your explanation! :} – Eduardo06sp Dec 28 '19 at 04:57
  • But in your git repository there is no package.json file. – code_aks Dec 28 '19 at 08:21
  • Do I need to upload it? It's not in my .gitignore or anything. https://i.postimg.cc/VNNQwVmh/Screenshot-2019-12-28-23-11-34.png – Eduardo06sp Dec 29 '19 at 07:14
  • 1
    Above is mine project repo screenshot you have to do the same thing push your package.json file also.. Because in error you can clearly se that heroku is finding for package.json file.. thanks and also you upvote my answer..it cost you nothing :) – code_aks Dec 29 '19 at 10:27
0

My package.json file was not present in my Github repository, although it does exist in my local system.

I had no pending files to be committed and my .gitignore shows no exclusion of any json files. I'm not sure why it wasn't uploaded to my repository.

So I had to force add it to the staging area by running: git add -f path/to/the/file (credit to @San's answer to a different question).

Then I simply committed the change and pushed to Heroku successfully!

Eduardo06sp
  • 331
  • 1
  • 4
  • 16