简体   繁体   English

使用纱线 Package 管理器时出错

[英]Errors using yarn Package Manager

I have been using npm to install packages using sudo before each command.我一直在使用 npm 在每个命令之前使用 sudo 安装软件包。 Considering that this is a bad practice, I have installed yarn in order to manage my packages.考虑到这是一种不好的做法,我安装了 yarn 来管理我的包。 After installing yarn and running a package installation, I am obtaining the following errors:安装纱线并运行 package 安装后,我收到以下错误:

info No lockfile found. info 未找到锁定文件。

Should I manually create this file, or yarn should be creating one on its own?我应该手动创建这个文件,还是 yarn 应该自己创建一个?

warning package-lock.json found.警告 package-lock.json 发现。 Your project contains lock files generated by tools other than Yarn.您的项目包含由 Yarn 以外的工具生成的锁定文件。 It is advised not to mix package managers in order to avoid resolution inconsistencies caused by unsynchronized lock files.建议不要混用package管理器,以免锁文件不同步导致解析不一致。 To clear this warning, remove package-lock.json.要清除此警告,请删除 package-lock.json。

If I clear the package-lock.json file, then npm will no longer find the packages.如果我清除 package-lock.json 文件,那么 npm 将不再找到这些包。 Do I need to uninstall all the packages that were initially installed using npm, and re-install everything if I wish to exclusively use yarn in the future?是否需要卸载所有最初使用 npm 安装的软件包,如果我希望将来专门使用 yarn,是否需要重新安装所有软件包? There are quite a few packages.有很多包。

error An unexpected error occurred: "EACCES: permission denied, mkdir '/home/username/node_modules/cacheable-request'".错误发生意外错误:“EACCES:权限被拒绝,mkdir'/home/username/node_modules/cacheable-request'”。

I suppose that this error is due to the fact that I had initially installed nodes with sudo permission.我想这个错误是由于我最初安装了具有 sudo 权限的节点。 How can I fix this permission issue?如何解决此权限问题?

Assuming you are using Linux (because of the sudo command).假设您使用的是 Linux(因为 sudo 命令)。

  • info No lockfile found. info 未找到锁定文件。

The first time yarn successfully installs dependencies it create the file.第一次 yarn 成功安装依赖项时,它会创建文件。

  • warning package-lock.json found警告 package-lock.json 发现

Just a Warning is not recommended to use both yarn and NPM but is not a problem.只是警告不建议同时使用纱线和 NPM 但不是问题。

  • error An unexpected error occurred: "EACCES: permission denied错误发生意外错误:“EACCES:权限被拒绝

You should be the owner of /home/<you_username>/node_modules to check this run this command ls -l ~/node_modules if the owner is the root (because of use sudo npm ) you can change to you again running sudo chown -R $USER ~/node_modules Then you should be able to run yarn again to install all your dependencies.你应该是 /home/<you_username>/node_modules 的所有者来检查这个运行这个命令ls -l ~/node_modules如果所有者是 root (因为使用sudo npm )你可以改变你再次运行sudo chown -R $USER ~/node_modules然后你应该能够再次运行yarn来安装所有依赖项。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM