[英]Why the express module is not installing in its default directory e.g., npm\node_modules?
I'm trying to install express module using the following commands: 我正在尝试使用以下命令安装Express模块:
npm install --save express
npm install -g express
npm install -g express-generator
After installation I was expecting the module to be created inside nodejs\\node_modules\\npm\\node_modules , Instead it is getting installed and created in somewhere else (In C:\\Users\\$SudoName\\AppData\\Roaming\\npm\\node_modules ). 安装后,我期望模块将在nodejs \\ node_modules \\ npm \\ node_modules中创建 ,而不是在其他地方安装和创建(在C:\\ Users \\ $ SudoName \\ AppData \\ Roaming \\ npm \\ node_modules中 )。
Therefore while running the project node is unable to locate the express module in it's own directory where it suppose to be. 因此,在运行项目节点时,无法在它自己的目录中找到快速模块。
Let's explain your commands step by step: 让我们逐步解释您的命令:
$ npm install --save express
The --save command is used when you want to save a package for distribution. 当您要保存软件包以进行分发时,将使用--save命令。 This command saves the package under your dependencies section of your package.json file.
此命令将软件包保存在package.json文件的“ dependencies”部分下。
$ npm install -g express
From the documentation : "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附加到命令中),它将当前程序包上下文(即,当前工作目录)安装为全局程序包。”
In your case: C:\\Users\\$SudoName\\AppData\\Roaming\\npm\\node_modules 在您的情况下: C:\\ Users \\ $ SudoName \\ AppData \\ Roaming \\ npm \\ node_modules
Note : You can see where your packages are installed using: 注意 :您可以使用以下方法查看软件包的安装位置:
$ npm list -g
Finally, 最后,
$ npm install -g express-generator
gets the same approach. 得到相同的方法。 It gets installed under your global dependencies.
它在您的全局依赖项下安装。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.