Gary Vaughan Jr
Gary Vaughan Jr

Reputation: 91

Why is Heroku telling me it cannot find a package.json in my module when I do a heroku push

I created my own npm package from a fork of react-coverflow. It appears to be working fine in my app locally using it this way: "npm install react-coverflow-mod" --save.

I can run my app using "run with debug (F5)" in VsCode and npm start on the client folder to start the React front end.

Then I do an npm run build on the client folder, and it works just fine.

When I do a heroku push it fails everytime with this error:


npm ERR! code ENOLOCAL
npm ERR! Could not install from "../../react-coverflow-mod" 
as it does not contain a package.json file.

1. I know there is a package.json in the module because I can install it via "npm install react-coverflow-mod": https://www.npmjs.com/package/react-coverflow-mod

2. The installed module has a package.json file in it

3. My github repo has a package.json in it: https://github.com/leroyvaughan/react-coverflow

I'm not sure how I can fix this. Do I need a package.json to go into the /Dist folder? What is wrong here with Heroku.

Upvotes: 1

Views: 955

Answers (1)

sebastienbarbier
sebastienbarbier

Reputation: 6832

It seams like heroku try to install a package from a relative path instead of the published name. That would perfectly explain why you can run locally but not on a production environment.

Open your project and search for the exact string displayed in your log: "../../react-coverflow-mod" and you should be able to find quickly where it is.

If you run on a unix system (don't know about windows) you can do a search using grep:

grep -rnw '/path/to/somewhere/' -e '../../react-coverflow-mod'

Make sure it includes your root folder which contain package.json, and might we wise to ignore node_modules which is always massive.

Upvotes: 1

Related Questions