Nuget/npm/bower/typings 等包管理器的自定义路径
Custom paths for package managers like Nuget/npm/bower/typings
我正在 Visual Studio 中建立一个基于 AngularJS 和 Typescript 的项目,这有点令人沮丧,因为我需要安装依赖项时必须尽快处理另一个包管理器.
我遇到的问题是包管理器要求包含依赖项的文件位于特定位置。
我们以npm为例。
我把 packages.json 放在 ./SolutionDirectory/MyApp.Web/
但是当我 运行 npm install 时,我只是得到 ENOENT: No such file or directory. 因为 cwd 是 ./SolutionDirectory
如果我正在执行 cd ./SolutionDirectory/MyApp.Web 和 运行 npm install 之后它工作正常。
对于 bower,我能够通过传递额外的参数来处理类似的问题,例如:
bower 安装--config.cwd=./SolutionDirectory/MyApp.Web/app/lib--config.directory=vendor
此命令仅从 ./SolutionDirectory/MyApp.Web/app/lib 获取 bower.json 并将软件包安装到 ./SolutionDirectory/MyApp.Web/app/lib/vendor
有没有办法在安装前将 packages.json 位置传递给 npm?
有没有办法在安装前将 typings.json 位置传递给打字?传递安装的类型的目标目录位置?
Nuget 也一样吗?
- 有没有办法在安装前将 packages.json 位置传递给 npm?
不,没有。目前无法覆盖 npm 中的 cwd
值。你应该移动目录和 运行 它:
`$ cd SolutionDirectory/MyApp.Web/ && npm install`
下面是与此类似的讨论:https://github.com/npm/npm/pull/10958
- 有没有办法在安装前将 typings.json 位置传递给打字?传递安装的类型的目标目录位置?
从技术上讲是的,但我猜你只想用 typings.json
做 typings install
。如何将 typings.json
与 package.json
放在同一路径并使用 npm lifecycle script?
$ ls
package.json typings.json
$ cat package.json
{
"name": "name",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"postinstall": "typings install"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"typings": "^0.7.12"
}
}
$ npm install
=> after npm install, typings install will start with typings.json
- 对于 Nuget 是否同样可行?
Nuget 也是包管理器,所以它应该具有类似的功能,比如 nuget mirror
命令可以是 npm config set registry
和 nuget locales
可以是 npm cache
我猜。从技术上讲,这是一个不同的软件,但我认为了解这两个软件是了解彼此概念和总结的好方法。
对于 npm:
npm install <folder>
<folder>
是包含 package.json
文件的文件夹的路径。
打字:
typings install [<name>=]<location>
<location>
是 typings.json
的路径
对于 NuGet:
nuget install packageId|pathToPackagesConfig [options]
pathToPackagesConfig
是 packages.config
文件的路径。
所以,要回答这个问题,是的,可以为所有这些包管理器指定配置文件位置的路径。
我正在 Visual Studio 中建立一个基于 AngularJS 和 Typescript 的项目,这有点令人沮丧,因为我需要安装依赖项时必须尽快处理另一个包管理器.
我遇到的问题是包管理器要求包含依赖项的文件位于特定位置。
我们以npm为例。 我把 packages.json 放在 ./SolutionDirectory/MyApp.Web/ 但是当我 运行 npm install 时,我只是得到 ENOENT: No such file or directory. 因为 cwd 是 ./SolutionDirectory
如果我正在执行 cd ./SolutionDirectory/MyApp.Web 和 运行 npm install 之后它工作正常。
对于 bower,我能够通过传递额外的参数来处理类似的问题,例如:
bower 安装--config.cwd=./SolutionDirectory/MyApp.Web/app/lib--config.directory=vendor
此命令仅从 ./SolutionDirectory/MyApp.Web/app/lib 获取 bower.json 并将软件包安装到 ./SolutionDirectory/MyApp.Web/app/lib/vendor
有没有办法在安装前将 packages.json 位置传递给 npm?
有没有办法在安装前将 typings.json 位置传递给打字?传递安装的类型的目标目录位置?
Nuget 也一样吗?
- 有没有办法在安装前将 packages.json 位置传递给 npm?
不,没有。目前无法覆盖 npm 中的 cwd
值。你应该移动目录和 运行 它:
`$ cd SolutionDirectory/MyApp.Web/ && npm install`
下面是与此类似的讨论:https://github.com/npm/npm/pull/10958
- 有没有办法在安装前将 typings.json 位置传递给打字?传递安装的类型的目标目录位置?
从技术上讲是的,但我猜你只想用 typings.json
做 typings install
。如何将 typings.json
与 package.json
放在同一路径并使用 npm lifecycle script?
$ ls
package.json typings.json
$ cat package.json
{
"name": "name",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"postinstall": "typings install"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"typings": "^0.7.12"
}
}
$ npm install
=> after npm install, typings install will start with typings.json
- 对于 Nuget 是否同样可行?
Nuget 也是包管理器,所以它应该具有类似的功能,比如 nuget mirror
命令可以是 npm config set registry
和 nuget locales
可以是 npm cache
我猜。从技术上讲,这是一个不同的软件,但我认为了解这两个软件是了解彼此概念和总结的好方法。
对于 npm:
npm install <folder>
<folder>
是包含 package.json
文件的文件夹的路径。
打字:
typings install [<name>=]<location>
<location>
是 typings.json
对于 NuGet:
nuget install packageId|pathToPackagesConfig [options]
pathToPackagesConfig
是 packages.config
文件的路径。
所以,要回答这个问题,是的,可以为所有这些包管理器指定配置文件位置的路径。