[英]Adding dependencies in package.json of an express project
Assume the following scenario. 假定以下情况。 Suppose I am developing an express project named test
. 假设我正在开发一个名为test
的快递项目。 In that project I am using a node module named x
. 在该项目中,我正在使用名为x
的节点模块。 x
uses another module named y
. x
使用另一个名为y
模块。 I have already added x
to the dependencies of package.json
of project test
. 我已经将x
添加到项目test
的package.json
的依赖项中。 Do I need to add y
too? 我也需要添加y
吗? Simple intuition says I don't need to but it's causing me problem. 简单的直觉说我不需要,但是这给我带来了麻烦。 Any help? 有什么帮助吗?
To answer your question, yes you need to add y
. 要回答您的问题,是的,您需要添加y
。 From what I understand, it works the other way around. 据我了解,它反过来起作用。 If you have y
already installed as your projects dependency, x
won't need to install it as its dependency. 如果您已经安装了y
作为您的项目依赖项,则x
不需要安装它作为其依赖项。
Node looks at the upper level directories (before looking at the current directory) if there are present node_modules
folders, and searches them if the module you are looking for is already present. 如果存在node_modules
文件夹,Node会查看上一级目录(在查看当前目录之前),如果正在寻找的模块已经存在, node_modules
搜索它们。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.