好名字可以让我的朋友更容易记住我624 2023-04-06 23:34 采纳率: 50%
浏览 56
已结题

yarn install无法在规定位置生成node_module文件夹

问题描述:

已经在项目package.json所在根目录 ./my_project 的 .yarnrc文件 中规定好了安装位置:

> --install.modules-folder "./media/node_modules"
--add.modules-folder "./media/node_modules"
registry "https://registry.yarnpkg.com"

但yarn install 运行约1-2分钟后过后无法在 ./my_project/media/node_modules文件夹生成所需要的依赖,该文件夹是空的。
cmd运行过程如下:

> (ENV) C:\my_project\my_project>yarn install
yarn install v1.22.19
warning package.json: No license field
info No lockfile found.
info Plug'n'Play support has been greatly improved on the Yarn v2 development branch.
info Please give it a try and tell us what you think! - https://next.yarnpkg.com/getting-started/install
warning my_project: No license field
[1/5] Resolving packages...
warning arches > @mapbox/mapbox-gl-draw > @mapbox/geojsonhint@2.2.0: Please make plans to check GeoJSON in some other way
warning arches > @turf/turf > @turf/bezier@4.7.3: Module has been renamed to @turf/bezier-spline
warning arches > @turf/turf > @turf/inside@4.7.3: Module has been renamed to @turf/boolean-point-in-polygon
warning arches > @turf/turf > @turf/collect > @turf/inside@4.7.3: Module has been renamed to @turf/boolean-point-in-polygon
warning arches > @turf/turf > @turf/isobands > @turf/inside@3.14.0: Module has been renamed to @turf/boolean-point-in-polygon
warning arches > @turf/turf > @turf/line-distance@4.7.3: Module deprecated in favor of @turf/length
warning arches > @turf/turf > @turf/line-chunk > @turf/line-distance@4.7.3: Module deprecated in favor of @turf/length
warning arches > @turf/turf > @turf/linestring-to-polygon@4.7.3: Module has been renamed to @turf/line-to-polygon
warning arches > @turf/turf > @turf/nearest@4.7.3: Module has been renamed to @turf/nearest-point
warning arches > @turf/turf > @turf/point-grid > @turf/inside@4.7.3: Module has been renamed to @turf/boolean-point-in-polygon
warning arches > @turf/turf > @turf/point-on-surface@4.7.3: Module has been renamed to @turf/point-on-feature
warning arches > @turf/turf > @turf/point-on-surface > @turf/inside@4.7.3: Module has been renamed to @turf/boolean-point-in-polygon
warning arches > @turf/turf > @turf/polygon-to-linestring@4.7.3: Module has been renamed to @turf/polygon-to-line
warning arches > @turf/turf > @turf/point-on-line@4.7.3: Module has been renamed to @turf/nearest-point-on-line
warning arches > @turf/turf > @turf/line-overlap > @turf/point-on-line@4.7.3: Module has been renamed to @turf/nearest-point-on-line
warning arches > @turf/turf > @turf/line-slice > @turf/point-on-line@4.7.3: Module has been renamed to @turf/nearest-point-on-line
warning arches > @turf/turf > @turf/line-split > @turf/point-on-line@4.7.3: Module has been renamed to @turf/nearest-point-on-line
warning arches > @turf/turf > @turf/tag > @turf/inside@4.7.3: Module has been renamed to @turf/boolean-point-in-polygon
warning arches > @turf/turf > @turf/within@4.7.3: Module has been renamed to @turf/points-within-polygon
warning arches > @turf/turf > @turf/within > @turf/inside@4.7.3: Module has been renamed to @turf/boolean-point-in-polygon
warning arches > @turf/turf > @turf/polygonize > polygonize > @turf/inside@4.7.3: Module has been renamed to @turf/boolean-point-in-polygon
warning arches > @mapbox/geojsonhint > jsonlint-lines > nomnom@1.8.1: Package no longer supported. Contact support@npmjs.com for more info.
warning arches > @turf/turf > @turf/unkink-polygon > simplepolygon > @turf/inside@4.7.3: Module has been renamed to @turf/boolean-point-in-polygon
warning arches > @turf/turf > @turf/unkink-polygon > simplepolygon > @turf/within@3.14.0: Module has been renamed to @turf/points-within-polygon
warning arches > @turf/turf > @turf/unkink-polygon > simplepolygon > @turf/within > @turf/inside@3.14.0: Module has been renamed to @turf/boolean-point-in-polygon
warning arches-dev-dependencies > node-sass > request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
warning arches-dev-dependencies > node-sass > request > har-validator@5.1.5: this library is no longer supported
warning arches-dev-dependencies > node-sass > request > uuid@3.4.0: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
warning arches-dev-dependencies > node-sass > node-gyp > make-fetch-happen > cacache > @npmcli/move-file@1.1.2: This functionality has been moved to @npmcli/fs
[2/5] Fetching packages...
[3/5] Linking dependencies...
[5/5] Building fresh packages...
success Saved lockfile.
Done in 121.28s.

操作环境、软件版本等信息:

win 10命令行,yarn 1.22.19

尝试过的解决方法:
  1. 清除缓存yarn cache clean, 删除yarn.lock和package-lock.json文件,再试。
    运行1-2分钟后,目标文件夹node_modules依然是空的
  2. 使用npm i命令。
    npm i 运行结束后在 ./my_project根目录下直接生成了node_modules文件夹,里面安装的依赖齐全。但也无法生成在 ./my_project/media内。
我想要达到的结果:

使用yarn 1.22.19,yarn install命令能将需要的依赖下载在 ./media/node_modules 中

  • 写回答

1条回答 默认 最新

  • 丘比特惩罚陆 Java领域新星创作者 2023-04-07 08:22
    关注

    可以尝试以下步骤,以确保 yarn 可以正确地将依赖项安装在指定的目录中:

    确保您在运行 yarn install 命令时,当前工作目录是 my_project/media,而不是 my_project。

    删除 my_project/media 下的 node_modules 文件夹(如果有的话),以便重新安装依赖项。

    在 my_project/media 目录中创建一个 package.json 文件,可以使用 yarn init 命令来创建。

    在 package.json 文件中添加您需要安装的依赖项

    {
      "dependencies": {
        "dependency1": "^1.0.0",
        "dependency2": "^2.0.0"
      }
    }
    

    这里的 "dependency1" 和 "dependency2" 是您需要安装的依赖项的名称和版本号。

    运行 yarn install 命令,确保您在 my_project/media 目录中运行该命令。Yarn 将自动将依赖项安装在 my_project/media/node_modules 目录中。

    如果这些步骤不起作用,您可以尝试更新 Yarn 版本,或者使用 npm 安装依赖项。

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

问题事件

  • 系统已结题 4月18日
  • 已采纳回答 4月10日
  • 创建了问题 4月6日

悬赏问题

  • ¥50 adb连接不到手机是怎么回事?
  • ¥20 抓取数据时发生错误: get_mooncake_data() missing 1 required positional argument: 'driver'的问题,怎么改出正确的爬虫代码?
  • ¥15 vs2022无法联网
  • ¥15 TCP的客户端和服务器的互联
  • ¥15 VB.NET操作免驱摄像头
  • ¥15 笔记本上移动热点开关状态查询
  • ¥85 类鸟群Boids——仿真鸟群避障的相关问题
  • ¥15 CFEDEM自带算例错误,如何解决?
  • ¥15 有没有会使用flac3d软件的家人
  • ¥20 360摄像头无法解绑使用,请教解绑当前账号绑定问题,