I am trying to install express into my current "directory".
However node installs this globally and I do not understand, how I can tell node to install it in my current directory.
我正在尝试将express安装到我当前的“目录”中。但是节点全局安装,我不明白,我怎么能告诉节点将它安装在我当前的目录中。
2 个解决方案
#1
0
I asked this back when I was a terminal noob. The solution was simple:
当我还是一个终端菜鸟时,我回答了这个问题。解决方案很简单:
CD (navigate using the command line) to the directory you want to install the module in and then it should work fine. It is a good idea to npm init
first.
CD(使用命令行导航)到您要安装模块的目录,然后它应该可以正常工作。首先是npm init是一个好主意。
#2
-1
Use
使用
npm install packagename
This will install the dependencies in the local node_modules folder.
这将在本地node_modules文件夹中安装依赖项。
In global mode (ie, with -g or --global appended to the command), it installs the current package context (ie, the current working directory) as a global package.
在全局模式下(即,使用-g或--global附加到命令),它将当前包上下文(即当前工作目录)安装为全局包。
So the default install location is local directory, and you need to specify -g or --global to install the modules globally.
因此,默认安装位置是本地目录,您需要指定-g或--global以全局安装模块。
Check out the official docs for more info: https://docs.npmjs.com/cli/install
查看官方文档了解更多信息:https://docs.npmjs.com/cli/install
#1
0
I asked this back when I was a terminal noob. The solution was simple:
当我还是一个终端菜鸟时,我回答了这个问题。解决方案很简单:
CD (navigate using the command line) to the directory you want to install the module in and then it should work fine. It is a good idea to npm init
first.
CD(使用命令行导航)到您要安装模块的目录,然后它应该可以正常工作。首先是npm init是一个好主意。
#2
-1
Use
使用
npm install packagename
This will install the dependencies in the local node_modules folder.
这将在本地node_modules文件夹中安装依赖项。
In global mode (ie, with -g or --global appended to the command), it installs the current package context (ie, the current working directory) as a global package.
在全局模式下(即,使用-g或--global附加到命令),它将当前包上下文(即当前工作目录)安装为全局包。
So the default install location is local directory, and you need to specify -g or --global to install the modules globally.
因此,默认安装位置是本地目录,您需要指定-g或--global以全局安装模块。
Check out the official docs for more info: https://docs.npmjs.com/cli/install
查看官方文档了解更多信息:https://docs.npmjs.com/cli/install