使用yarn运行一个前端项目时报了个错:
tianlang@tianlang-VirtualBox:/data/code/java/master$ yarn
yarn install v1.22.10
$ echo $npm_execpath | grep -q yarn || echo '033[0;33mSorry, npm is not supported. Please use Yarn (https://yarnpkg.com/).033[0m'
[1/5] Validating package.json...
[2/5] Resolving packages...
[3/5] Fetching packages...
info fsevents@1.2.13: The platform "linux" is incompatible with this module.
info "fsevents@1.2.13" is an optional dependency and failed compatibility check. Excluding it from installation.
info fsevents@2.1.3: The platform "linux" is incompatible with this module.
info "fsevents@2.1.3" is an optional dependency and failed compatibility check. Excluding it from installation.
[4/5] Linking dependencies...
warning " > @cypress/webpack-preprocessor@4.1.5" has incorrect peer dependency "webpack@^4.18.1".
warning " > @testing-library/cypress@5.3.1" has incorrect peer dependency "cypress@^2.1.0 || ^3.0.0 || ^4.0.0".
warning " > eslint-loader@4.0.2" has incorrect peer dependency "webpack@^4.0.0 || ^5.0.0".
warning " > eslint-plugin-react@6.10.3" has incorrect peer dependency "eslint@^2.0.0 || ^3.0.0".
warning " > postcss-cssnext@2.11.0" has unmet peer dependency "caniuse-db@^1.0.30000652".
error An unexpected error occurred: "EPERM: operation not permitted, symlink '../../../parser/bin/babel-parser.js' -> '/data/code/java/metabase-master/node_modules/@babel/core/node_modules/.bin/parser'".
info If you think this is a bug, please open a bug report with the information provided in "/data/code/java/metabase-master/yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
刚开始以为是babel包没有下载成功导致的,尝试删除依赖重新执行了几次依然不见好转,再仔细检查错误信息,考虑到时创建软链接时出现了问题,直接在命令行中手动创建一个软链接测试:
tianlang@tianlang-VirtualBox:/data/code/java/master$ ln -s yarn-error.log error.log
ln: failed to create symbolic link 'error.log': Operation not permitted
还真是没权限创建软链接,考虑到使用的是Vbox虚拟机,就搜索了下Vbox开启使用软链接的配置:
执行命令前先关闭虚拟机
D:Program FilesOracleVirtualBox>VBoxManage setextradata "elementary" VBoxInternal2/SharedFoldersEnableSymlinksCreate/code 1
其中`elementary`是虚拟机名称,`code`是共享文件夹名称,具体使用方式可以参考:
https://www.cnblogs.com/cxbhakim/p/8882947.html
执行成功后正常启动虚拟机,再次执行创建软链接的命令:
tianlang@tianlang-VirtualBox:/data/code/java/master$ ln -s yarn-error.log error.log
ln: failed to create symbolic link 'error.log': Protocol error
虽然还是没有成功但报错信息不一样了,看来设置已经起作用了,接下来关闭虚拟机,关闭VboxManager, 然后以管理员身份运行VboxManager
再启动虚拟机,执行创建软链接命令,成功创建软链接。
再次执行yarn,也能成功执行了.