Define npm scripts in your package.json
:
"start": "ember serve",
"test": "ember exam --load-balance --parallel=4",
"lint": "npm-run-all --parallel --aggregate-output lint:**",
and use those scripts, don't use global commands.
Bad: ember test
(yes, it's bad even if you see it in the official docs)
Good: npm test
There are several benefits to using npm scripts instead of global commands:
- No chance of local vs global package version mismatch that can lead to inexplicable errors
- No chance of using the wrong command and/or options (for example, the default command for running tests in Ember projects is
ember test
, but a project might useember exam
and/or additional options like--load-balance --parallel=4
) - No need to remember specific commands for each type of project, because
npm start
andnpm test
are standard commands used by virtually every JavaScript project, be it an Ember project, a React project, or an Express project - No need to install global packages, keep track of their versions, and update them
If you really need to run a one-off command, use npx, it will protect you from local vs global package version mismatch (because it uses local package if it detects one):
npx prettier --write .
Top comments (0)