package.json中的本地依赖关系 [英] Local dependency in package.json

查看:2100
本文介绍了package.json中的本地依赖关系的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想做这样的事情,所以npm install还会安装../somelocallibpackage.json或更重要的是它的依赖项.

I want to do something like this, so npm install also installs the package.json of ../somelocallib or more importantly its dependencies.

"dependencies": {
    "express": "*",
    "../somelocallib": "*"
}

推荐答案

npm> = 2.0.0

此功能已在npm 2.0.0版本中实现 .示例:

{
  "name": "baz",
  "dependencies": {
    "bar": "file:../foo/bar"
  }
}

以下任何路径均有效:

../foo/bar
~/foo/bar
./foo/bar
/foo/bar

本地软件包将 复制 前缀(./node-modules).

somelocallib作为依赖项正常放置在您的package.json中:

Put somelocallib as dependency in your package.json as normal:

"dependencies": {
  "somelocallib": "0.0.x"
}

然后运行npm link ../somelocallib和npm,将您正在使用的版本安装为符号链接.

Then run npm link ../somelocallib and npm will install the version you're working on as a symlink.

app@0.0.1 /private/tmp/app
└── somelocallib@0.0.1 -> /private/tmp/somelocallib

参考:链接(1)

这篇关于package.json中的本地依赖关系的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆