Skip to content

Commit 90945e6

Browse files
chore: set npm as default package manager to init (#2503)
* set npm as default package manager to init * update docs
1 parent a414d98 commit 90945e6

File tree

4 files changed

+8
-11
lines changed

4 files changed

+8
-11
lines changed

__e2e__/init.test.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,10 @@ function createCustomTemplateFiles() {
2222

2323
const customTemplateCopiedFiles = [
2424
'.git',
25-
'.yarn',
26-
'.yarnrc.yml', // .yarnrc.yml for Yarn versions >= 2.0.0
2725
'dir',
2826
'file',
29-
'node_modules',
27+
'package-lock.json',
3028
'package.json',
31-
'yarn.lock',
3229
];
3330

3431
beforeEach(() => {
@@ -150,7 +147,7 @@ test('init skips installation of dependencies with --skip-install', () => {
150147

151148
expect(dirFiles).toEqual(
152149
customTemplateCopiedFiles.filter(
153-
(file) => !['node_modules', 'yarn.lock'].includes(file),
150+
(file) => !['node_modules', 'package-lock.json'].includes(file),
154151
),
155152
);
156153
});

docs/init.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ There are couple of ways to initialize new React Native projects.
66
npx react-native@latest init ProjectName
77
```
88

9-
> Note: If you have both `yarn` and `npm` installed on your machine, React Native CLI will always try to use `yarn`, so even if you use `npx` utility, only `react-native` executable will be installed using `npm` and the rest of the work will be delegated to `yarn`. You can force usage of `npm` adding `--pm npm` flag to the command.
9+
> Note: If you have both `yarn` and `npm` installed on your machine, React Native CLI will always try to use `npm`. You can force usage of `yarn` by adding `--pm yarn` flag to the command.
1010
1111
> Note: for Yarn users, `yarn dlx` command similar to `npx` will be featured in Yarn 2.0: <https://github.com/yarnpkg/berry/pull/40> so we'll be able to use it in a similar fashion.
1212
@@ -49,10 +49,10 @@ npx react-native@latest init ProjectName --template ${TEMPLATE_NAME}
4949
npx react-native@${VERSION} init ProjectName --template ${TEMPLATE_NAME}
5050
```
5151

52-
You can force usage of `npm` if you have both `yarn` and `npm` installed on your machine:
52+
You can force usage of `yarn` if you have both `yarn` and `npm` installed on your machine:
5353

5454
```sh
55-
npx react-native@latest init ProjectName --pm npm
55+
npx react-native@latest init ProjectName --pm yarn
5656
```
5757

5858
## Creating custom template

packages/cli/src/commands/init/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export default {
1919
{
2020
name: '--pm <string>',
2121
description:
22-
'Use specific package manager to initialize the project. Available options: `yarn`, `npm`, `bun`. Default: `yarn`',
22+
'Use specific package manager to initialize the project. Available options: `yarn`, `npm`, `bun`. Default: `npm`',
2323
},
2424
{
2525
name: '--directory <string>',

packages/cli/src/commands/init/init.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,8 +207,8 @@ async function createFromTemplate({
207207
packageManager = pm;
208208
} else {
209209
const userAgentPM = userAgentPackageManager();
210-
// if possible, use the package manager from the user agent. Otherwise fallback to default (yarn)
211-
packageManager = userAgentPM || 'yarn';
210+
// if possible, use the package manager from the user agent. Otherwise fallback to default (npm)
211+
packageManager = userAgentPM || 'npm';
212212
}
213213

214214
// if the project with the name already has cache, remove the cache to avoid problems with pods installation

0 commit comments

Comments
 (0)