重新安装纱线问题-代码:"MODULE_NOT_FOUND" [英] Issue reinstalling yarn - code: 'MODULE_NOT_FOUND'

查看:110
本文介绍了重新安装纱线问题-代码:"MODULE_NOT_FOUND"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  • Node.js版本:14.0.0
  • 操作系统:MacOS 10.15.4
  • 范围(安装,代码,运行时,元数据,其他?):纱线安装
  • 模块(和版本)(如果相关):internal/modules/cjs/loader.js
  • Node.js Version:14.0.0
  • OS: MacOS 10.15.4
  • Scope (install, code, runtime, meta, other?): Yarn install
  • Module (and version) (if relevant): internal/modules/cjs/loader.js

在运行任何 Yarn 命令时,我收到以下错误.这是在重新安装后并按照以下命令顺序进行的:

Upon running any Yarn command, I get the following error. This is after reinstalling and following this sequence of commands:

纱线失速:

清理纱线缓存

  1. 打开终端
  2. rm -rf node_modules yarn.lock yarn-error.log包-lock.json
  3. 酿造卸载--force纱线
  4. npm卸载-g纱线
  5. 纱线-v
  6. 哪根纱
  7. rm -rf〜/.yarn(可选,不推荐)
  8. rm -rf/usr/local/bin/yarn
  9. rm -rf/usr/local/bin/yarnpkg
  10. 哪根纱

NPM和节点卸载:

  1. 继续添加到终端
  2. 酿造卸载--force节点
  3. 啤酒清理
  4. sudo rm -rf/usr/local/{lib/node {,/.npm,_modules},bin,share/man}/{npm *,node *,man1/node *}
  5. sudo rm -rf/usr/local/bin/npm/usr/local/share/man/man1/node */usr/local/lib/dtrace/node.d〜/.npm〜/.node-gyp
  6. sudo rm -rf/opt/local/bin/node/opt/local/include/node/opt/local/lib/node_modules
  7. sudo rm -rf/usr/local/bin/npm/usr/local/share/man/man1/node.1/usr/local/lib/dtrace/node.d
  8. 酿酒医生
  9. brew cleanup --prune-prefix

安装:

  1. 同一终端
  2. 酿制纱线
  3. 酿造安装节点
  4. brew链接节点
  5. sudo chmod 776/usr/local/lib
  6. brew link --overwrite节点
  7. sudo chmod 755/usr/local/lib
  8. brew链接节点
  9. 纱线政策集版本
  10. n 12.13.1

    11.纱线-v&&节点-v&&npm -v

然后,在安装的第9步运行yarn命令时,以下内容将出现在终端上:

Then the following appears on terminal upon running yarn command at step 9 of the install:

USER-MacBook-Pro:~ User$ yarn
internal/modules/cjs/loader.js:1017
  throw err;
  ^

Error: Cannot find module '/Users/jlagos/.yarn/releases/yarn-1.21.1.js'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:1014:15)
    at Function.Module._load (internal/modules/cjs/loader.js:884:27)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
    at internal/main/run_main_module.js:17:47 {
  code: 'MODULE_NOT_FOUND',
  requireStack: [ ]
}

有关如何恢复纱线的任何帮助吗?似乎节点正在跟踪以前的纱线版本.

Any help on how to restore Yarn? Seems like node is keeping track of a previous yarn version.

推荐答案

每当我更新yarn时,我仍然遇到相同的问题.$ PATH中可能存在的某些东西(目前尚不可见),我尚无法删除.

I keep running into the same issue whenever I update yarn as well. Something possibly in the (currently unseen) $PATH that I've yet to be able to remove.

@jlagos指出,您可以通过在该位置上复制最新版本来欺骗系统运行最新版本而不是1.21.1.

As @jlagos pointed out, you can trick the system to run the latest version instead of 1.21.1 by copying over the latest over that location.

如果尚未安装或在/.yarn/上看到yarn,可以直接在

If you have yet to install or see yarn at /.yarn/ you can install it directly following https://classic.yarnpkg.com/en/docs/install/ or

curl -o- -L https://yarnpkg.com/install.sh |bash

然后使用以下命令创建并复制文件位置:

Then create and copy of the file location with the following:

mkdir ~/.yarn/releases/
cp ~/.yarn/lib/cli.js ~/.yarn/releases/yarn-1.21.1.js

yarn --version

现在运行纱线时,它应该显示最新的状态(例如在撰写本文时为1.22.5).

When running yarn, it should now state the latest (such as 1.22.5 at the time of writing).

这篇关于重新安装纱线问题-代码:"MODULE_NOT_FOUND"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆