Version using yarn instead of npm please?
invegat opened this issue · 6 comments
- clone or fork this repo
- run
yarn install
- commit the resulting
yarn.lock
lockfile - deploy to Heroku
To run yarn at all with "git push heroku master" needed to git rm both package-lock.json files, haven't found any yarn replacement for "npm install --only=dev " of "heroku-postbuild": "cd react-ui/ && npm install && npm install --only=dev --no-shrinkwrap && npm run build
If you move the entries in react-ui/package.json devDependencies
to dependencies
, then that dev deps command is not necessary, could be changed to:
"heroku-postbuild": "cd react-ui/ && yarn install && npm run build"
The whole reason that --only=dev --no-shrinkwrap
exists is to work with the React app exactly as it's produced by create-react-app.
Wow, thanks, that worked.
Using all yarn also worked. "heroku-postbuild": "cd react-ui/ && yarn install && yarn build"
Here is how I incorporated yarn:
- delete
package-lock.json
- run the
yarn
command. This creates theyarn.lock
file so that Heroku knows you are using yarn. Withoutyarn.lock
Heroku will try to use NPM instead and your build will fail. - under scripts:
"heroku-postbuild": "cd react-ui/ && yarn --production=false && yarn build"
yarn --production=false
takes the place ofnpm install && npm install --only=dev --no-shrinkwrap
. Not sure if--no-shrinkwrap
is relevant to yarn. My test worked fine.
This way you can keep react-scripts
as a dev dependency and use yarn as well.