Skip to content

Commit

Permalink
Fix install command with older versions of npm
Browse files Browse the repository at this point in the history
Older versions of Node come with npm@6, which doesn't have the npm exec
command (and may or may not have npx). Instead of relying on that
tool just call the binary directly. This also means we can ensure we're
using the same version of node as the caller.
  • Loading branch information
lfdebrux committed Sep 2, 2022
1 parent b2df17e commit b64fc76
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions bin/cli
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,10 @@ function isSafeToCreateProjectIn (root, name) {
const packageSpec = argv[4] || 'govuk-prototype-kit'

await fs.writeFile(path.join(installDirectory, 'package.json'), '{}' + os.EOL, 'utf8')
execSync(`npm install ${packageSpec}`, { stdio: 'inherit' })
console.log(`Installing ${packageSpec}, this may take a few minutes...`)
execSync(`npm install ${packageSpec}`, { stdio: 'ignore' })
execSync(
`npm exec -- govuk-prototype-kit install -- ${installDirectory}`,
`${process.execPath} node_modules/.bin/govuk-prototype-kit install -- ${installDirectory}`,
{
env: { LANG: process.env.LANG, PATH: process.env.PATH }, // clearing the env of any npm_ stuff is important,
// otherwise npx won't be able to use the package we just installed
Expand Down

0 comments on commit b64fc76

Please sign in to comment.