Skip to content

Commit 88a5ab8

Browse files
authored
Cleaned up wording and explanation around npm linking
1 parent 31454f7 commit 88a5ab8

File tree

1 file changed

+25
-16
lines changed

1 file changed

+25
-16
lines changed

README.md

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -30,29 +30,38 @@ Then go to [http://localhost:8601/](http://localhost:8601/) - the playground out
3030

3131
## Developing alongside other Scratch repositories
3232

33-
### Linking this code to another project's `node_modules/scratch-gui`
33+
### Getting another repo to point to this code
3434

35-
#### Configuration
3635

37-
If you wish to develop scratch-gui alongside other scratch repositories that depend on it, you may wish
38-
to have the other repositories use your local scratch-gui build instead of fetching the current production
36+
If you wish to develop `scratch-gui` alongside other scratch repositories that depend on it, you may wish
37+
to have the other repositories use your local `scratch-gui` build instead of fetching the current production
3938
version of the scratch-gui that is found by default using `npm install`.
4039

41-
To do this:
42-
1. Make sure you have run `npm install` from this (scratch-gui) repository's top level
43-
2. Make sure you have run `npm install` from the top level of each repository (such as scratch-www) that depends on scratch-gui
44-
3. From this (scratch-gui) repository's top level, build the `dist` directory by running `BUILD_MODE=dist npm run build`
45-
4. From this (scratch-gui) repository's top level, establish a link to this repository by running `npm link`
46-
5. From the top level of each repository that depends on scratch-gui, run `npm link scratch-gui`
47-
6. Build or run the repositories that depend on scratch-gui
40+
Here's how to link your local `scratch-gui` code to another project's `node_modules/scratch-gui`.
41+
42+
#### Configuration
43+
44+
1. In your local `scratch-gui` repository's top level:
45+
1. Make sure you have run `npm install`
46+
2. Build the `dist` directory by running `BUILD_MODE=dist npm run build`
47+
3. Establish a link to this repository by running `npm link`
4848

49-
Instead of `BUILD_MODE=dist npm run build` you can also use `BUILD_MODE=dist npm run watch`, however this may be unreliable.
49+
2. From the top level of each repository (such as `scratch-www`) that depends on `scratch-gui`:
50+
1. Make sure you have run `npm install`
51+
2. Run `npm link scratch-gui`
52+
3. Build or run the repositoriy
53+
54+
#### Using `npm run watch`
55+
56+
Instead of `BUILD_MODE=dist npm run build`, you can use `BUILD_MODE=dist npm run watch` instead. This will watch for changes to your `scratch-gui` code, and automatically rebuild when there are changes. Sometimes this has been unreliable; if you are having problems, try going back to `BUILD_MODE=dist npm run build` until you resolve them.
5057

5158
#### Oh no! It didn't work!
52-
* Follow the recipe above step by step and don't change the order. It is especially important to run npm first because installing after the linking will reset the linking.
53-
* Make sure the repositories are siblings on your machine's file tree.
54-
* If you have multiple Terminal tabs or windows open for the different Scratch repositories, make sure to use the same node version in all of them.
55-
* In the worst case unlink the repositories by running `npm unlink` in both, and start over.
59+
60+
If you can't get linking to work right, try:
61+
* Follow the recipe above step by step and don't change the order. It is especially important to run `npm install` _before_ `npm link`, because installing after the linking will reset the linking.
62+
* Make sure the repositories are siblings on your machine's file tree, like `.../.../MY_SCRATCH_DEV_DIRECTORY/scratch-gui/` and `.../.../MY_SCRATCH_DEV_DIRECTORY/scratch-www/`.
63+
* Consistent node.js version: If you have multiple Terminal tabs or windows open for the different Scratch repositories, make sure to use the same node version in all of them.
64+
* If nothing else works, unlink the repositories by running `npm unlink` in both, and start over.
5665

5766
## Testing
5867
### Documentation

0 commit comments

Comments
 (0)