<commit_before># npm Notes

See http://browsenpm.org/help for another npm cheat sheet.


## Initializing a Package

```sh
npm init
```

**Scoped**

```sh
npm init --scope=my-scope
```

```sh
npm init --scope=username
```

### Version Controlled Package Initialization Examples

For these examples, Github is used as the SCM.

**Local-First**

```sh
cd ${REPO_DIR}
cd ${NPM_SCOPE_DIR} # Optional
mkdir ${PACKAGE_NAME}
cd ${PACKAGE_NAME}
git flow init
npm init --scope=${NPM_SCOPE} # Exclude the '@' prefix.
```

* Create a new repo in your Github account.
  + Choose a name.
  + Add a description. (Likely the same as the description used in `package.json`.
  + Choose public or private.
  + Initialize with a README if you haven't added one yet.<commit_msg>Add a Workspaces sub-section<commit_after># npm Notes

See http://browsenpm.org/help for another npm cheat sheet.


## Initializing a Package

```sh
npm init
```

**Scoped**

```sh
npm init --scope=my-scope
```

```sh
npm init --scope=username
```

**Workspaces**

First, initialize a package like normal. See the commands above. Then you add workspaces using the following syntax:

```sh
npm init -w|--workspace <path/workspace-name> [-w|--workspace <path/workspace-name> ...]
# E.g.
npm init --workspace ./packages/foo --w ./libraries/bar --w ./applications/foo
```

Note: The workspaces may have the same name with a different path but the `name` property of each workspace's `package.json` must be unique.

### Version Controlled Package Initialization Examples

For these examples, Github is used as the SCM.

**Local-First**

```sh
cd ${REPO_DIR}
cd ${NPM_SCOPE_DIR} # Optional
mkdir ${PACKAGE_NAME}
cd ${PACKAGE_NAME}
git flow init
npm init --scope=${NPM_SCOPE} # Exclude the '@' prefix.
```

* Create a new repo in your Github account.
  + Choose a name.
  + Add a description. (Likely the same as the description used in `package.json`.
  + Choose public or private.
  + Initialize with a README if you haven't added one yet.
{'fraction_non_alphanumeric': 0.12857860371672528, 'fraction_numerical': 0.0, 'mean_word_length': 3.9064039408866993, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1019223', 'n_tokens_mistral': 682, 'n_tokens_neox': 632, 'n_words': 252}