node.js 拒绝安装 sqlite3 作为自身的依赖
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11940086/
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
Refusing to install sqlite3 as a dependency of itself
提问by Dorothyy
I have the most recent version of node.js built with no problems. I am trying to use a sqlite module for node.js.
我有最新版本的 node.js,没有任何问题。我正在尝试为 node.js 使用 sqlite 模块。
For node-sqlite3 by developmentseed, I followed the directions:
对于 developmentseed 的 node-sqlite3,我遵循了以下说明:
git clone git://github.com/developmentseed/node-sqlite3.git
cd node-sqlite3
./configure
make
I installed npm with: curl -k https://npmjs.org/install.sh| sudo sh
我安装了 npm: curl -k https://npmjs.org/install.sh| 须藤
and installed node-gyp with npm: sudo npm install -g node-gyp
并使用 npm 安装 node-gyp: sudo npm install -g node-gyp
After node-sqlite3 configure-d and make-d okay, I tried to install with npm, I get this:
在 node-sqlite3 configure-d 和 make-d 之后,我尝试用 npm 安装,我得到这个:
npm install sqlite3
npm WARN install Refusing to install sqlite3 as a dependency of itself
When I researched this error, I found this question: npm install sqlite3 errorso I tried:
当我研究这个错误时,我发现了这个问题:npm install sqlite3 error所以我尝试了:
node-waf clean || true; node-waf configure build
but got this error:
但得到这个错误:
/usr/local/bin/../lib/node/wafadmin/Utils.py:136: DeprecationWarning: the md5 module is deprecated; use hashlib instead
from md5 import md5
Waf: Please run waf from a directory containing a file named "wscript" or run distclean
/usr/local/bin/../lib/node/wafadmin/Utils.py:136: DeprecationWarning: the md5 module is deprecated; use hashlib instead
from md5 import md5
arg[0] directory does not contain a wscript file
When I tried to build orlandov/node-sqlite, I got it from git and then tried:
当我尝试构建 orlandov/node-sqlite 时,我从 git 中得到它,然后尝试:
node-waf configure build
but I get this error:
但我收到此错误:
/usr/local/bin/../lib/node/wafadmin/Utils.py:136: DeprecationWarning: the md5 module is
deprecated; use hashlib instead
from md5 import md5
Checking for program g++ or c++ : /usr/bin/g++
Checking for program cpp : /usr/bin/cpp
Checking for program ar : /nnmc/cvsbin/ar
Checking for program ranlib : /usr/bin/ranlib
Checking for g++ : ok
Checking for program gcc or cc : cc
Checking for gcc : ok
Checking for node path : not found
Checking for node prefix : ok /usr/local
'configure' finished successfully (0.070s)
Waf: Entering directory `/U1/dorothyy/project_node/node-sqlite/build'
/U1/dorothyy/project_node/node-sqlite/deps/mpool-2.1.0
make: Nothing to be done for `all'.
Waf: Leaving directory `/U1/dorothyy/project_node/node-sqlite/build'
Traceback (most recent call last):
File "/usr/local/bin/node-waf", line 16, in <module>
Scripting.prepare(t, os.getcwd(), VERSION, wafdir)
File "/usr/local/bin/../lib/node/wafadmin/Scripting.py", line 145, in prepare
prepare_impl(t, cwd, ver, wafdir)
File "/usr/local/bin/../lib/node/wafadmin/Scripting.py", line 135, in prepare_impl
main()
File "/usr/local/bin/../lib/node/wafadmin/Scripting.py", line 188, in main
fun(ctx)
File "/usr/local/bin/../lib/node/wafadmin/Scripting.py", line 386, in build
return build_impl(bld)
File "/usr/local/bin/../lib/node/wafadmin/Scripting.py", line 405, in build_impl
bld.compile()
File "/usr/local/bin/../lib/node/wafadmin/Build.py", line 255, in compile
self.flush()
File "/usr/local/bin/../lib/node/wafadmin/Build.py", line 717, in flush
tg.post()
File "/usr/local/bin/../lib/node/wafadmin/TaskGen.py", line 219, in post
self.apply()
File "/usr/local/bin/../lib/node/wafadmin/TaskGen.py", line 206, in apply
v()
File "/usr/local/bin/../lib/node/wafadmin/TaskGen.py", line 464, in apply_core
node = find_resource(filename)
File "/usr/local/bin/../lib/node/wafadmin/Node.py", line 183, in find_resource
st = Utils.h_file(path)
AttributeError: 'module' object has no attribute 'h_file'
I cannot use grumdrig/node-sqlite because it does not support asynchronous access.
我不能使用 grumdrig/node-sqlite,因为它不支持异步访问。
Thank you for any suggestions.
谢谢你的任何建议。
采纳答案by Vadim Baryshev
You don't need to execute
你不需要执行
npm install sqlite3
in node-sqlite3 folder. By executing this command you trying to install sqlite3 as dependency of sqlite3 (you already have it).
在 node-sqlite3 文件夹中。通过执行此命令,您尝试将 sqlite3 安装为 sqlite3 的依赖项(您已经拥有它)。
There are two ways to install sqlite3:
安装sqlite3有两种方式:
First:
第一的:
In your project folder execute
在您的项目文件夹中执行
npm install sqlite3
You dont need to clone git project before it. Don't need to configure and make it manually. Just execute this command in your project folder where you want to use sqlite3 module. You should see folder node_modules/sqlite3 in your project folder after npm finish. Now you can use it in your project by require:
你不需要在它之前克隆 git 项目。不需要手动配置和制作。只需在要使用 sqlite3 模块的项目文件夹中执行此命令。npm 完成后,您应该会在项目文件夹中看到文件夹 node_modules/sqlite3。现在你可以通过 require 在你的项目中使用它:
var sqlite3 = require('sqlite3');
Second:
第二:
Use this way only if npm install fails. (Paranormal).
仅当 npm install 失败时才使用这种方式。(超自然现象)。
- Go to your project folder.
- Create folder node_modules if not exists.
Execute:
git clone git://github.com/developmentseed/node-sqlite3.git cd node-sqlite3 ./configure makeOk. Now sqlite3 half-ready to use. We need to install dependencies. Execute:
npm installAttention:npm install without other parameters. This command use package.json in your sqlite3 folder to install dependencies.
- 转到您的项目文件夹。
- 如果不存在,则创建文件夹 node_modules。
执行:
git clone git://github.com/developmentseed/node-sqlite3.git cd node-sqlite3 ./configure make好的。现在sqlite3 已经可以使用了。我们需要安装依赖项。执行:
npm install注意:npm install 不带其他参数。此命令使用 sqlite3 文件夹中的 package.json 来安装依赖项。
After npm finish you can use sqlite3 module in your project.
npm 完成后,您可以在项目中使用 sqlite3 模块。
回答by Simon H
I got this error when my app had the same name as one of the packages I was (npm) installing. I was just doing some practise and had not thought I needed a unique name for the project...
当我的应用程序与我 (npm) 安装的软件包之一同名时,我收到此错误。我只是在做一些练习,没想到我需要为项目起一个唯一的名字……
Just change the namein your package.jsonto something else and it should work.
只需将name您的内容更改package.json为其他内容即可。
回答by marcinsdance
Just leave the directory of the module you want to install and try to install it again. This worked for me. So:
只需离开您要安装的模块的目录,然后再次尝试安装即可。这对我有用。所以:
cd ..
npm install sqlite3
回答by Ignatius Andrew
Check if your project folder name is same as the module you are trying to install,
检查您的项目文件夹名称是否与您尝试安装的模块相同,
If you try to install express inside a project folder name express, you will get this error.
如果您尝试在名为 express 的项目文件夹中安装 express,则会出现此错误。
Rename your Project Folder, Your project Folder name should be unique compared to the npm module names
重命名您的项目文件夹,与 npm 模块名称相比,您的项目文件夹名称应该是唯一的
Also change the package.json file entry
还要更改 package.json 文件条目
"name": "xxxxx",
"version": "1.0.0",
回答by Naveen Gupta
This Error occurs when your package name is same as package you are going to install.
Go to package.jsoncheck name property init
当您的软件包名称与您要安装的软件包名称相同时,会发生此错误。
去package.json检查名称属性init
{
name:"xxxx",
...
}
May be it will help.
可能会有所帮助。
回答by Dalchand Kumawat
I guess in the package.json file, the name of the project is sqlite3. So when you try to install that it rejects due to some reasons as mentioned that it becomes dependency. So try to change the name of project in package.json and give a try. For further reference checkout :http://thisdavej.com/node-newbie-error-npm-refusing-to-install-package-as-a-dependency-of-itself/
我猜在package.json文件中,项目的名字是sqlite3。因此,当您尝试安装它时,由于某些原因,它会拒绝它成为依赖项。所以尝试在 package.json 中更改项目名称并尝试一下。如需进一步参考结帐:http: //thisdavej.com/node-newbie-error-npm-refusing-to-install-package-as-a-dependency-of-itself/

