1. Problem description

If you create an empty directory umi-app and run the yarn create @umijs/umi-app command, or run the yarn create umi umi-app command without creating an empty directory, the following error message is displayed:

λ yarn Create @umijs/umi-app Yarn Create v1.22.4 [1/4] considerations packages... [2/4] Fetching packages... The info to [email protected]: The platform "win32" is incompatible with this module. info "[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation. [3/4] Linking dependencies... Warning "creation-umi > Sylvanas > @umijs/ Fabric > @typescript-eslint/[email protected]" has incorrect peer dependency "@typescript-eslint/parser@^1.9.0". Warning "create-umi > Sylvanas > @umijs/ Fabric > [email protected]" has Incorrect peer dependency "eslint-plugin-react@^7.14.2". Warning "@umijs/ creation-umi-app > @umijs/utils > @babel/[email protected]" has unmet peer dependency "@babel/core@^7.0.0-0". [4/4] Building fresh packages... Success Installed "@umijs/[email protected]" with binaries: - create-umi-app The file name, directory name or volume slogan method is incorrect. error Command failed. Exit code: 1 Command: M:\nodejs\node_global\bin\create-umi-app Arguments: Directory: L:\workspace\ReactProjects\umi-app Output: info Visit https://yarnpkg.com/en/docs/cli/create for documentation about this command.Copy the code

λ yarn Create umi umi-app YARN Create v1.22.4 [1/4] considerations... [2/4] Fetching packages... [3/4] Linking dependencies... Warning "creation-umi > Sylvanas > @umijs/ Fabric > @typescript-eslint/[email protected]" has incorrect peer dependency "@typescript-eslint/parser@^1.9.0". Warning "create-umi > Sylvanas > @umijs/ Fabric > [email protected]" has Incorrect peer dependency "eslint-plugin-react@^7.14.2". [4/4] Building fresh packages... Success Installed "[email protected]" with binaries: - create-umi The file name, directory name, or volume label method is incorrect. error Command failed. Exit code: 1 Command: M:\nodejs\node_global\bin\create-umi Arguments: Directory: L:\workspace\ReactProjects\umi-app Output: info Visit https://yarnpkg.com/en/docs/cli/create for documentation about this command.Copy the code

2. Problem analysis

Check the error message and recall that NPM install -g YARN is used to install YARN, and the bin file directory of the global yarn module is not changed after yarn is installed. After the yarn module is installed globally, the bin file is in the bin file directory of the global module installation directory set by NPM. Command is displayed in the error message: M: \ nodejs \ node_global \ bin \ the create – umi, Then look at the create-umi. CMD file and find the code @”%~dp0\C:\Users\love2\AppData\Local\Yarn\Data\global\node_modules\.bin\create-umi. CMD “% * CMD file in the default YARN bin directory. Node “%~dp0\.. \create-umi\cli.js” %*, however, found no create-umi folder in C: Users\love2\AppData\Local\Yarn\global\node_modules\, Therefore, an error message is displayed indicating that the file name, directory name, or volume label is incorrect. In this case, you need to change the default bin file directory of YARN and change the default global module installation directory and cache directory to other disks to save space on drive C.

3. Solutions

  • Directory before modification
λ yarn global dir C:\Users\love2\AppData\Local\ yarn \Data\global # global cache directory λ yarn cache dir C:\Users\love2\AppData\Local\Yarn\Cache\v6 # global module bin file directory λ Yarn global bin M:\nodejs\node_global binCopy the code
  • Modified directory
Set global module installation directory attribute name: Global-folder λ yarn config set global-folder" M:\nodejs\yarn_global" yarn config v1.22.4 Success set "global-Folder" To "M:\\nodejs\\yarn_global". Done in 0.06s. Cache-folder λ yarn config set cache-folder" M:\nodejs\yarn_cache" yarn config v1.22.4 success set "cache-folder" to "M:\\nodejs\\yarn_cache". Done in 0.06s. λ yarn config set prefix M:\nodejs\yarn_global\node_modules\. Bin yarn config v1.22.4 success set "prefix" to "M: \ \ nodejs \ \ yarn_global \ \ node_modules \ \ bin", Done in 0.06 s. Note: The yarn config set prefix command does not work. The command cannot be found in CMD. After the yarn config list command is executed, the yarn config list command does not contain the prefix attribute. Therefore, add M:\nodejs\yarn_global\node_modules\.bin to pathCopy the code