已经在项目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
使用yarn 1.22.19,yarn install命令能将需要的依赖下载在 ./media/node_modules 中
可以尝试以下步骤,以确保 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 安装依赖项。