Skip to content

Commit e0f67e0

Browse files
BasitAlithymikee
authored andcommitted
fix: set project directory to install packages in init command (#262)
Fixes #260 and facebook/react-native#24103 by setting project directory on PackageManager which is needed to check for yarn.lock file. Summary: --------- I'm not sure how to test this but creating new projects fail with the exception ``` info Adding required dependencies internal/validators.js:125 throw new ERR_INVALID_ARG_TYPE(name, 'string', value); ^ TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type undefined at validateString (internal/validators.js:125:11) at Object.join (path.js:1147:7) at isProjectUsingYarn (/path/to/app/node_modules/@react-native-community/cli/build/tools/yarn.js:101:51) at shouldUseYarn (/path/to/app/node_modules/@react-native-community/cli/build/tools/PackageManager.js:36:39) at Object.install (/path/to/app/node_modules/@react-native-community/cli/build/tools/PackageManager.js:44:10) at generateProject (/path/to/app/node_modules/@react-native-community/cli/build/commands/init/init.js:111:18) at Object.init (/path/to/app/node_modules/@react-native-community/cli/build/commands/init/init.js:94:3) at run (/Users/xxx/.config/yarn/global/node_modules/react-native-cli/index.js:302:7) at createProject (/Users/xxx/.config/yarn/global/node_modules/react-native-cli/index.js:249:3) at init (/Users/xxx/.config/yarn/global/node_modules/react-native-cli/index.js:200:5) ``` The error seems to be stemming from passing `undefined` for `projectDir` to `path.join`. Added a line to fix this. Test Plan: ---------- `react-native init TestProject` should not fail.
1 parent 35ecc18 commit e0f67e0

File tree

1 file changed

+1
-0
lines changed
  • packages/cli/src/commands/init

1 file changed

+1
-0
lines changed

packages/cli/src/commands/init/init.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ function generateProject(destinationRoot, newProjectName, options) {
5252
const pkgJson = require('react-native/package.json');
5353
const reactVersion = pkgJson.peerDependencies.react;
5454

55+
PackageManager.setProjectDir(destinationRoot);
5556
createProjectFromTemplate(
5657
destinationRoot,
5758
newProjectName,

0 commit comments

Comments
 (0)