node.js 如何安装node-mysql?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/16280784/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-02 14:21:24  来源:igfitidea点击:

How to install node-mysql?

node.jswindows-7node-mysql

提问by Filipe Tagliacozzi

Im in windows 7 cmd prompt,,, Im trying to instal by: npm install node-mysql

我在 Windows 7 cmd 提示符下,我试图通过以下方式安装: npm install node-mysql

Im getting this:

我得到这个:

C:\Program Files\nodejs>npm install node-mysql
npm http GET https://registry.npmjs.org/node-mysql
npm http 404 https://registry.npmjs.org/node-mysql
npm ERR! 404 'node-mysql' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it
npm ERR! 404
npm ERR! 404 Maybe try 'npm search mysql'
npm ERR! 404
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, or http url, or git url.

npm ERR! System Windows_NT 6.1.7600
npm ERR! command "C:\Program Files\nodejs\\node.exe" "C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js" "install" "node-mysql"
npm ERR! cwd C:\Program Files\nodejs
npm ERR! node -v v0.10.4
npm ERR! npm -v 1.2.18
npm ERR! code E404
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR!     C:\Program Files\nodejs\npm-debug.log
npm ERR! not ok code 0

How to fix it? Im trying to search npm search node-mysql,, and I cant found it in the list

如何解决?我正在尝试搜索npm search node-mysql,但在列表中找不到它

回答by Tadeusz Wójcik

Try:

尝试:

npm install mysql

Node-msql (https://github.com/felixge/node-mysql/blob/master/package.json) is named simply mysql in package.json and it exists under that name in npm registry.

Node-msql ( https://github.com/felixge/node-mysql/blob/master/package.json) 在 package.json 中被简单地命名为 mysql ,它在 npm 注册表中以该名称存在。

回答by kasim badami

Try

尝试

npm install felixge/node-mysql

Reference : readme.md from https://github.com/felixge/node-mysql

参考:来自https://github.com/felixge/node-mysql 的readme.md

回答by Sun Love

Following are the steps for adding the mysql module for node js

下面是为node js添加mysql模块的步骤

1 Open your command prompt

1 打开命令提示符

type npm install g-mysql for global use.

输入 npm install g-mysql 供全球使用。

It will take time. mysql module will not get installed in the nodejs module directory. Please copy the module from the administrator directory to nodejs module folder.

需要花时间。mysql 模块不会安装在 nodejs 模块目录中。请将模块从管理员目录复制到 nodejs 模块文件夹。

To check the module is installed or not please go to node js command line and type

要检查模块是否安装,请转到 node js 命令行并键入

require_resolve('mysql');

require_resolve('mysql');

path to the module will be shown

将显示模块的路径

回答by Sonpal singh Sengar

Please follow the given steps, which work for me:

请按照给定的步骤操作,这对我有用:

  1. Make a folder named mysqlin this location:

    C:\Users\newusers\AppData\Roaming\npm\node_modules
    
  2. Then run the command npm -g install mysql

  1. mysql在此位置创建一个文件夹:

    C:\Users\newusers\AppData\Roaming\npm\node_modules
    
  2. 然后运行命令 npm -g install mysql

回答by chirag parikh

You can use below commands to use mysql globally

您可以使用以下命令全局使用 mysql

npm install mysql -g