简体   繁体   English

为什么Express模块​​没有安装在其默认目录中,例如npm \\ node_modules?

[英]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.

相关问题 为什么 npm 安装不安装包到 /node_modules 文件夹? - Why is npm install not installing packages into /node_modules folder? 使用外部JS文件捆绑TypeScript(例如node_modules) - Bundle TypeScript with external JS files (e.g. node_modules) node.js / npm-覆盖本地默认模块目录(node_modules) - node.js / npm - override local default modules directory (node_modules) 安装 Drivelist 时找不到模块 'C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin' - Cannot find module 'C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\bin' While installing Drivelist NPM是否在node_modules下安装非根依赖关系? - NPM Installing non root dependencies under node_modules? 错误:在 ReactJS 项目中运行 npm 后找不到模块“serialize-javascript”,即使它存在于目录 node_modules - Error: Cannot find module 'serialize-javascript' after running npm start in ReactJS project, even though there it exists in directory node_modules 为什么我的npm package的所有文件都安装在node_modules中? - Why all files of my npm package are installed in node_modules? 无法加载我手动放在/ node_modules /目录中的模块 - Cannot load module I put manually in /node_modules/ directory Node/Express:为什么不能将 res 传递给帮助程序 function(例如用于验证)并避免 ERR_HTTP_HEADERS_SENT? - Node/Express: Why can't you pass res to a helper function (e.g. for validation) and avoid ERR_HTTP_HEADERS_SENT? 为什么Grunt在node_modules中安装了这么多文件夹? - Why is Grunt installing so many folders in node_modules?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM