gpt4 book ai didi

javascript - 如何引用计算机上全局安装的依赖项?

转载 作者:行者123 更新时间:2023-12-03 12:40:37 26 4
gpt4 key购买 nike

我正在构建一个包(我们称之为项目 a),我试图将其包含在另一个项目(项目 b)中。

在项目 b 中,我的 package.json 中有这个

...
"dependencies": {
"a": "C:\\Users\\myuser\\AppData\\Roaming\\npm\\node_modules\\a"
},
...

但是当我在项目 b 中运行 npm install 时,出现错误:

npm ERR! notarget No compatible version found: 1@'C:\Users\myuser\AppData\Roaming\npm\node_modules\a'
npm ERR! notarget Valid install targets:
npm ERR! notarget ["1.0.0","1.0.1","1.0.2","1.0.3","1.0.4","1.0.5","1.0.6"]

版本 1.0.0 - 1.0.6 已发布(尽管不起作用)。

为什么 npm install 不查看我指定的路径,而是查看 NPM 公共(public)存储库?

最佳答案

因为这不是 npm 识别的源类型。参见package.json(5):

dependencies
Dependencies are specified with a simple hash of package name to ver‐
sion range. The version range is a string which has one or more
space-separated descriptors. Dependencies can also be identified with
a tarball or git URL.

Please do not put test harnesses or transpilers in your dependencies
hash. See devDependencies, below.

npm help See semver for more details about specifying version ranges.

· version Must match version exactly

· >version Must be greater than version

· >=version etc

· <version

· <=version

· npm help ~version "Approximately equivalent to version" See
semver

· npm help ^version "Compatible with version" See semver

· 1.2.x 1.2.0, 1.2.1, etc., but not 1.3.0

· http://... See 'URLs as Dependencies' below

· * Matches any version

· "" (just an empty string) Same as *

· version1 - version2 Same as >=version1 <=version2.

· range1 || range2 Passes if either range1 or range2 are satisfied.

· git... See 'Git URLs as Dependencies' below

· user/repo See 'GitHub URLs' below

C:\Users\myuser\AppData\Roaming\npm\node_modules\a内运行npm link,并在包中设置常规依赖项。 json.

关于javascript - 如何引用计算机上全局安装的依赖项?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23544556/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com