enriikke / gatsby-gh-pages-action

GitHub Action to build and deploy your Gatsby site to GitHub Pages ❤️🎩
MIT License
295 stars 62 forks source link

Action fails when using npm #5

Closed antoncarlsson closed 5 years ago

antoncarlsson commented 5 years ago

The action fails if you are using npm as your package manager.

Ready to build your Gatsby site!
Building with: npm run gatsby build 
npm run gatsby build 
npm ERR! missing script: gatsby

This is because npm run gatsby build causes npm to look for a script called gatsby. This is not a problem for yarn, since yarn run gatsby build actually runs gatsby build.

Temporary solution for anyone using npm

Create a script in your package.json called gatsby:

"gatsby": "gatsby build"

Proposed solution

Instead of trying to run gatsby build, run the build script that Gatsby automatically generates in package.json.

console.log(`Building with: ${pkgManager} run build ${gatsbyArgs}`)
await exec.exec(`${pkgManager} run build`, [gatsbyArgs])
enriikke commented 5 years ago

Closed via https://github.com/enriikke/gatsby-gh-pages-action/pull/6

Thank you again @antoncarlsson!