Skip to content

Commit a1720b7

Browse files
committed
Fill out readme
1 parent e961da9 commit a1720b7

File tree

1 file changed

+50
-2
lines changed

1 file changed

+50
-2
lines changed

Diff for: README.md

+50-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,50 @@
1-
# npw
2-
A workspace-aware npm wrapper to aid with developing in monorepos
1+
# @ampproject/npw
2+
3+
> A workspace-aware npm wrapper to aid with developing in monorepos
4+
5+
`npw` aids when developing a sub-package inside a [npm workspace][workspaces]
6+
monorepo. It allows you to cd into your sub-package and perform
7+
workspace-aware operations without you having to cd back into the
8+
monorepo root to perform the operation.
9+
10+
Imagine you have the following workspace setup:
11+
12+
```
13+
monorepo/
14+
packages/
15+
project-1/
16+
package.json
17+
project-2/
18+
package.json // { "dependencies": { "project-1": * } }
19+
package.json // { "workspaces": [ "./packages/*" ] }
20+
```
21+
22+
If you `cd monorepo` and run `npm install`, everything will work fine.
23+
But if you `cd packages/project-2` and try running `npm install` again,
24+
you'll get a failure that `project-1` cannot be resolved. This is
25+
because npm isn't aware you're working in a workspace's sub-package, so
26+
it doesn't know that `project-1` is in the parent directory.
27+
28+
`npw` fixes this. When you run `npw install`, it will figure out where
29+
the monorepo root is and perform the correct `npm install -w packages/project-2`
30+
so that npm is aware of the workspace.
31+
32+
## Installation
33+
34+
```bash
35+
$ npm install -g @ampproject/npw
36+
```
37+
38+
## Usage
39+
40+
`npw` is a simple wrapper around npm, and can be invoked with any
41+
command that npm supports.
42+
43+
44+
```bash
45+
$ npw install --save-dev prettier
46+
47+
$ npw start
48+
```
49+
50+
[workspaces]: https://docs.npmjs.com/cli/v7/using-npm/workspaces

0 commit comments

Comments
 (0)