ubuntu node_modules在yarn安装或npm安装后未在react应用程序中创建

yhuiod9q  于 2023-10-17  发布在  Yarn
关注(0)|答案(1)|浏览(217)

我有一个在Windows上运行良好的React项目。我只是在Ubuntu 22.04上克隆了它,并试图运行yarn从package.json文件中安装包,但在尝试安装所有包后,我得到了一些警告,比如这个包已被弃用,但最后一切看起来都很好,没有严重的错误,但目录中没有node_modules。当然,项目不会运行错误,

  1. yarn start
  2. Internal Error: my-proj@workspace:.: This package doesn't seem to be present in your lockfile; run "yarn install" to update the lockfile
  3. at V0.getCandidates (/home/hamed/.cache/node/corepack/yarn/3.6.0/yarn.js:435:5145)
  4. at kf.getCandidates (/home/hamed/.cache/node/corepack/yarn/3.6.0/yarn.js:391:1264)
  5. at /home/hamed/.cache/node/corepack/yarn/3.6.0/yarn.js:439:8033
  6. at df (/home/hamed/.cache/node/corepack/yarn/3.6.0/yarn.js:390:11070)
  7. at ge (/home/hamed/.cache/node/corepack/yarn/3.6.0/yarn.js:439:8013)

npm配置列表:

  1. ; cli configs
  2. metrics-registry = "https://registry.npmjs.org/"
  3. scope = ""
  4. user-agent = "npm/6.14.18 node/v14.21.3 linux x64"
  5. ; node bin location = /usr/bin/node
  6. ; cwd = /home/hamed/programming/projects/my-proj
  7. ; HOME = /home/hamed
  8. ; "npm config ls -l" to show all defaults.

节点版本:14.21.3 npm版本:6.14.18Yarn版本:3.6.0
在项目的根目录下有一个yarn.lock文件。

ffx8fchx

ffx8fchx1#

Yarn在最新的3.x版本中改变了很多,现在他们使用.yarn文件夹而不是node_modules,在您启动应用程序后,他们会根据您使用的模块生成node_modules文件夹。
如果你使用typescript,你必须配置你的编辑器,就像文档在这里说的那样:https://yarnpkg.com/getting-started/editor-sdks
如果使用的是Vscode,请在项目根文件夹yarn dlx @yarnpkg/sdks vscode中运行此命令

相关问题