Skip to content

Commit 955ff3f

Browse files
MajorBreakfastskipjack
authored andcommitted
docs(guides): use npx in getting-started (#1708)
Keep the mention the webpack binary's path but use the `npx` utility now that it ships with Node. Fix some punctuation and grammar. Clarify why npm scripts are still useful even over `npx`.
1 parent afe298d commit 955ff3f

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/content/guides/getting-started.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,10 +141,10 @@ __dist/index.html__
141141

142142
In this setup, `index.js` explicitly requires `lodash` to be present, and binds it as `_` (no global scope pollution). By stating what dependencies a module needs, webpack can use this information to build a dependency graph. It then uses the graph to generate an optimized bundle where scripts will be executed in the correct order.
143143

144-
With that said, let's run `webpack` with our script as the [entry point](/concepts/entry-points) and `bundle.js` as the [output](/concepts/output):
144+
With that said, let's run `npx webpack` with our script as the [entry point](/concepts/entry-points) and `bundle.js` as the [output](/concepts/output). The `npx` command, which ships with Node 8.2 or higher, runs the webpack binary (`./node_modules/.bin/webpack`) of the webpack package we installed in the beginning:
145145

146146
``` bash
147-
./node_modules/.bin/webpack src/index.js dist/bundle.js
147+
npx webpack src/index.js dist/bundle.js
148148

149149
Hash: ff6c1d39b26f89b3b7bb
150150
Version: webpack 2.2.0
@@ -204,7 +204,7 @@ module.exports = {
204204
Now, let's run the build again but instead using our new configuration:
205205

206206
``` bash
207-
./node_modules/.bin/webpack --config webpack.config.js
207+
npx webpack --config webpack.config.js
208208

209209
Hash: ff6c1d39b26f89b3b7bb
210210
Version: webpack 2.2.0
@@ -240,7 +240,7 @@ __package.json__
240240
}
241241
```
242242

243-
Now the `npm run build` command can be used in place of the longer commands we used earlier. Note that within `scripts` we can reference locally installed npm packages by name instead of writing out the entire path. This convention is the standard in most npm-based projects and allows us to directly call `webpack`, instead of `./node_modules/.bin/webpack`
243+
Now the `npm run build` command can be used in place of the `npx` command we used earlier. Note that within `scripts` we can reference locally installed npm packages by name the same way we did with `npx`. This convention is the standard in most npm-based projects because it allows all contributors to use the same set of common scripts (each with flags like `--config` if necessary).
244244

245245
Now run the following command and see if your script alias works:
246246

0 commit comments

Comments
 (0)