specific error
When yarn was building the first Vite project, the command line reported an error: The filename, directory name, or volume label syntax is incorrect. (The filename, directory name, or volume label syntax is incorrect.)
info No lockfile found.
warning package-lock.json found. Your project contains lock files generated by tools other than Yarn. It is advised not to mix package managers in order to avoid resolution inconsistencies caused by unsynchronized lock files. To clear this warning, remove package-lock.json.
[
译文:package-lock警告。json。您的项目包含由Yarn以外的工具生成的锁文件。建议不要混合使用包管理器,以避免锁文件不同步导致的解析不一致。要清除此警告,请删除package-lock.json。
]
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
error An unexpected error occurred: "EPERM: operation not permitted, unlink 'D:\\xxx'".
info If you think this is a bug, please open a bug report with the information provided in "D:\\xxx".
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.
wrong reason
Yarn
The default installation path is on C
the disk. However, due to C
too little disk space, I have modified Yarn
the global path and cache path to D
the disk, but I have not modified the global executable file directory. Since the disk volume labels of the three paths do not match, an error like this will be reported: The filename, directory name, or volume label syntax is incorrect.
(The file name, directory name or volume label syntax is incorrect)
Use the following command to view the global path, cache path and global executable file directory:
View yarn global bin location
yarn global bin
View yarn global installation location
yarn global dir
View yarn global cache location
yarn cache dir
Solution
Modify path command
Change yarn global bin location
# yarn config set prefix "D:\NodeJS\Yarn\Data"
yarn config set prefix "D:\ProgramFiles\NodeJS\Yarn\Date"
Change yarn global installation location
# yarn config set global-folder "D:\NodeJS\Yarn\Data\global"
yarn config set global-folder "D:\ProgramFiles\NodeJS\Yarn\Date\global"
Change yarn global cache location
# yarn config set cache-folder "D:\NodeJS\Yarn\Cache"
yarn config set cache-folder "D:\ProgramFiles\NodeJS\Yarn\Cache"
Change yarn global link position
# yarn config set link-folder "D:\NodeJS\Yarn\Data\link"
yarn config set link-folder "D:\ProgramFiles\NodeJS\Yarn\Date\link"
Change the global base directory toD:\ProgramFiles\NodeJS\Yarn
yarn config set prefix 'D:\ProgramFiles\NodeJS\Yarn'
Then the global executable directory will be changed automatically. We once again view the global executable file directory through the command:
D:\myspace> yarn global bin
D:\ProgramFiles\NodeJS\Yarn\bin
Folder directory structure
D:.
└───yarn
├───bin
├───cache
└───global
Add system variables
Bundle
D:\yarn\global\node_modules\bin添加系统环境变量到Path中。
(Reference: https://segmentfault.com/a/1190000043503907#item-1)