Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add things about pnpm #290

Merged
merged 2 commits into from
Sep 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .local.dic
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ nginx
NiM
NTFS
PowerShell
pnpm
pre-made
Pre-Octane
preloading
Expand Down
5 changes: 5 additions & 0 deletions guides/advanced-use/cli-commands-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ ember addon <addon-name> <options...>
--skip-git (Boolean) (Default: false)
aliases: -sg
--yarn (Boolean)
--pnpm (Boolean)
--directory (String)
aliases: -dir <value>
--lang (String) Sets the base human language of the addon's own test application via index.html
Expand Down Expand Up @@ -645,6 +646,7 @@ ember init <glob-pattern> <options...>
uses {{ember-welcome-page}}. Use --no-welcome to
skip it.
--yarn (Boolean)
--pnpm (Boolean)
--name (String) (Default: "")
aliases: -n <value>
--lang (String) Sets the base human language of the application via index.html
Expand All @@ -666,6 +668,8 @@ ember install <addon-name> <options...>
aliases: -E, --exact
--yarn (Boolean) Use --yarn to enforce yarn
usage, or --no-yarn to enforce npm
--pnpm (Boolean) Use --pnpm to enforce pnpm
usage, or --no-pnpm to enforce npm
```

### `ember new`
Expand All @@ -691,6 +695,7 @@ ember new <app-name> <options...>
uses {{ember-welcome-page}}. Use --no-welcome to
skip it.
--yarn (Boolean)
--pnpm (Boolean)
--directory (String)
aliases: -dir <value>
--lang (String) Sets the base human language of the application via index.html
Expand Down
6 changes: 3 additions & 3 deletions guides/advanced-use/debugging.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,9 @@ the all-purpose technique of "turning it on and off" can apply to Ember CLI as w

Some common steps are to stop the server, try one or more of these steps, and start the server again:

- Run `npm install` or `yarn install`
- Delete the `node_modules` directory and run `npm install` or `yarn install`
- Delete the `dist` directory (found in apps with versions < 3.4), delete `node_modules`, and `npm install` or `yarn install`
- Run `npm install`, `yarn install`, or `pnpm install`
- Delete the `node_modules` directory and run `npm install`, `yarn install`, or `pnpm install`
- Delete the `dist` directory (found in apps with versions < 3.4), delete `node_modules`, and `npm install`, `yarn install`, or `pnpm install`

[1]: https://nodejs.org/api/debugger.html
[2]: https://docs.npmjs.com/cli/link
Expand Down
2 changes: 1 addition & 1 deletion guides/appendix/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ For a complete list of command line options run `ember help`.

Some configuration is exposed through your `package.json` file.

If you have a nested repo structure (e.g., a monorepo using yarn workspaces) and want to allow `ember s` from the root of the repo, you can configure your `package.json` to look like:
If you have a nested repo structure (e.g., a monorepo using pnpm or yarn workspaces) and want to allow `ember s` from the root of the repo, you can configure your `package.json` to look like:

```json {data-filename=package.json}
{
Expand Down
30 changes: 19 additions & 11 deletions guides/basic-use/assets-and-dependencies.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,33 +17,33 @@ The code itself goes in `node_modules` during `npm install`, just like in many n
plus folders like `vendor` and `public` that can hold many other files of the developer's choice

<!--
If addons are installed accidentally with `npm install` or `yarn install`,
If addons are installed accidentally with `npm install`, `yarn install`, or `pnpm install`,
the blueprints can be run with .... what?

Added by @maxwondercorn:
What is now below - were should it go in the guide

If you accidentally install an Ember addon using either npm or Yarn, the default blueprint will not run. To run the blueprint use:
If you accidentally install an Ember addon using either npm, Yarn, or pnpm, the default blueprint will not run. To run the blueprint use:

```shell
ember generate <addon-name>
```
-->

## npm and Yarn
## Package Managers

Ember CLI supports both [npm](https://www.npmjs.com) and [Yarn](https://yarnpkg.com/)
Ember CLI supports [npm](https://www.npmjs.com), [Yarn](https://yarnpkg.com/), and [pnpm](https://pnpm.io)
for node modules management.

By default, new apps use `npm`.
Both tools offer similar functionality, and which one to choose is up to
the developer's preference.
Dependencies listed in `package.json` can be installed with either `npm install` or `yarn install`. The files for those packages are added to the `node_modules` folder of the app.
Dependencies listed in `package.json` can be installed with `npm install`, `yarn install`, or `pnpm install`. The files for those packages are added to the `node_modules` folder of the app.

There are two ways to switch from `npm` to `yarn`.
Either include an option when the app is created, like `ember new --yarn`,
or run `yarn install` to generate a `yarn.lock` file.
Ember will detect the `yarn.lock` file and start using it instead
There are two ways to switch from the default package manager, `npm`.
Either include an option when the app is created, like `ember new --yarn` or `ember new --pnpm`,
or run `yarn install` or `pnpm install` to generate the package manager's associated lockfile file.
Ember will detect the lockfile and start using it instead
for any `ember install some-addon-name` commands.
Don't forget to delete the `package-lock.json` file if the app
already has one.
Expand All @@ -52,21 +52,29 @@ file are present, Ember CLI will default to using Yarn.
However, having both files causes confusion for collaborators and
is incompatible with some CI systems.

To switch from `yarn` to `npm`, delete the `yarn.lock`
To switch back to `npm`, delete the lockfile from your package manager
and run `npm install` to generate a `package-lock.json`.

To have Ember CLI use `yarn` by default for all new projects, create a `.ember-cli` file in your home directory with:
To have Ember CLI use `yarn` or `pnpm` by default for all new projects, create a `.ember-cli` file in your home directory with:

```json
{
"yarn": true
}
```

or
```json
{
"pnpm": true
}
```

Further documentation about npm and Yarn is available at their official
documentation pages:

* [npm](https://www.npmjs.com)
* [pnpm](https://pnpm.io)
* [Yarn](https://yarnpkg.com)

### The `node_modules` directory
Expand Down
2 changes: 1 addition & 1 deletion guides/basic-use/cli-commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ ember new camping-trip-tracker --yarn
### Learn more

- [Ember Quickstart Guide](https://guides.emberjs.com/release/getting-started/quick-start/) for creating a first app
- [npm and Yarn](../assets-and-dependencies/#npmandyarn) for more on using package managers with Ember CLI
- [npm, Yarn, and pnpm](../assets-and-dependencies/#package-managers) for more on using package managers with Ember CLI

## Serve the app locally

Expand Down
8 changes: 4 additions & 4 deletions guides/basic-use/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ Learn how to install the Ember CLI on Linux, Mac, and Windows.

## Prerequisites

* [npm](https://www.npmjs.com/get-npm) or [yarn](https://yarnpkg.com/en/docs/install)
* [npm](https://www.npmjs.com/get-npm), [yarn](https://yarnpkg.com/en/docs/install), or [pnpm](https://pnpm.io/installation)
* [git](https://git-scm.com/) is recommended, but not required
* Recent version of [node](https://nodejs.org/en/download/), which comes included in `yarn` or `npm`
* Mac and Linux users may need [Watchman](https://facebook.github.io/watchman/) (not the npm version!)

First, we need to have a package manager installed. A package manager installs new dependencies from the command line, whether they are used as commands or in the app itself.
Follow these installation instructions for [npm](https://www.npmjs.com/get-npm) or [yarn](https://yarnpkg.com/en/docs/install).
While these two tools have somewhat different features, both are compatible with Ember app development.
Follow these installation instructions for [npm](https://www.npmjs.com/get-npm), [yarn](https://yarnpkg.com/en/docs/install), or [pnpm](https://pnpm.io/installation).
While these tools have somewhat different features, both are compatible with Ember app development.

We'll know installation is successful when `npm --version` or `yarn --version` returns the version number.
We'll know installation is successful when `npm --version`, `yarn --version`, or `pnpm --version` returns the version number.

It is recommended to install the most recent LTS (long-term support) version of `node`.
Restart the console after installing your package manager.
Expand Down
2 changes: 1 addition & 1 deletion guides/writing-addons/addon-blueprints.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ The default blueprint is recognized because it normally has the same name as the

### Blueprints in development

When developing and testing your addon using either `npm link` or `yarn link` your addon's blueprint will not automatically run. To manually run and test the blue print you would use the following command:
When developing and testing your addon using `npm link`, `yarn link`, or `pnpm link` your addon's blueprint will not automatically run. To manually run and test the blue print you would use the following command:

```shell
ember generate <your-blueprint-name>
Expand Down
12 changes: 6 additions & 6 deletions guides/writing-addons/intro-tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,17 @@ Our goal is to be able to pass the `buttonLabel` value to the addon, just like w

### Trying out the addon template in an app

There are several options to see the addon in action. We could use `npm link` or `yarn link` to try it out locally or publish the addon online. We'll use `link` while we are still developing and testing.
There are several options to see the addon in action. We could use `npm link`, `yarn link`, or `pnpm link` to try it out locally or publish the addon online. We'll use `link` while we are still developing and testing.

**From the addon project directory:**
1. Since our addon uses a template, we need the template precompiler to be a `dependency` and not a `devDependency`. In the addon's `package.json`, move the entry for `ember-cli-htmlbars` into the `dependencies` listing. If this step is missed, there is a clear error message when we try to start the app that uses our addon.
2. `yarn install` or `npm install`
3. Run the command `yarn link` or `npm link`
2. `pnpm install`, `yarn install`, or `npm install`
3. Run the command `yarn link` or `npm link`. This step may be skipped if using `pnpm`.

**From the directory of the app using the addon:**
1. `yarn link <addon-name>` or `npm link <addon-name>`.
1. `pnpm link ../path/to-/the-addon`, `yarn link <addon-name>` or `npm link <addon-name>`.
2. In the Ember app's `package.json`, add a `devDependencies` entry for your addon, like `"addon-name": "*"`. The `*` means that it will include all version numbers of our addon.
3. Run `yarn install` or `npm install` in the app. (If you are using the app for the first time, you can use `npm install --prefer-offline` or `npm install --offline` instead. These alternative commands can speed up installation, because `npm install` checks the online npm registry for your addon instead of your local storage.)
3. Run `pnpm install`, `yarn install`, or `npm install` in the app. (If you are using the app for the first time, you can use `npm install --prefer-offline` or `npm install --offline` instead. These alternative commands can speed up installation, because `npm install` checks the online npm registry for your addon instead of your local storage.)
4. Add a reference to your addon's component somewhere in an app template, like `<ComponentName @buttonLabel="Register" />`
5. Run a local server with `ember serve` and visit [http://localhost:4200](http://localhost:4200)

Expand All @@ -69,7 +69,7 @@ We should now see our addon in action!
**Having problems?**
- Check to make sure that your `package.json` is valid, looking for missing commas or trailing commas.
- "Template precompiler" errors mean that you skipped Step 1 and 2 above.
- `404 not found` means we forgot to `yarn` or `npm install`
- `404 not found` means we forgot to `pnpm install`, `yarn install` or `npm install`
- Make sure all the files have been saved.
- Did you rename or relocate any files after they were created? This is prone to mistakes, and the resulting errors can be really strange. It is best to create files using the CLI.

Expand Down