最新消息:20190717 VPS服务器:Vultr新加坡,WordPress主题:大前端D8,统一介绍入口:关于

【已解决】npm install之后,结果也还是会出现 can not find module的错误

Node.js crifan 9108浏览 0评论

npm安装restify好像没成功,所以运行restify的示例代码,结果说找不到restify模块。

所以又去重新安装restify,结果中间有错误:

E:\Dev_Root\freelance\Elance\projects\GordonHo\node.js\restify>npm install restify
npm http GET https://registry.npmjs.org/restify
npm http 304 https://registry.npmjs.org/restify
npm http GET https://registry.npmjs.org/retry/0.6.0
npm http GET https://registry.npmjs.org/async/0.1.22
npm http GET https://registry.npmjs.org/bunyan/0.10.0
npm http GET https://registry.npmjs.org/byline/2.0.2
npm http GET https://registry.npmjs.org/http-signature/0.9.9
npm http GET https://registry.npmjs.org/formidable/1.0.11
npm http GET https://registry.npmjs.org/lru-cache/1.1.0
npm http GET https://registry.npmjs.org/mime/1.2.5
npm http GET https://registry.npmjs.org/node-uuid/1.3.3
npm http GET https://registry.npmjs.org/dtrace-provider/0.0.9
npm http GET https://registry.npmjs.org/qs/0.5.0
npm http GET https://registry.npmjs.org/semver/1.0.14
npm http 200 https://registry.npmjs.org/retry/0.6.0
npm http 304 https://registry.npmjs.org/http-signature/0.9.9
npm http GET https://registry.npmjs.org/retry/-/retry-0.6.0.tgz
npm http 304 https://registry.npmjs.org/async/0.1.22
npm http 304 https://registry.npmjs.org/bunyan/0.10.0
npm http 304 https://registry.npmjs.org/byline/2.0.2
npm http 304 https://registry.npmjs.org/lru-cache/1.1.0
npm http 304 https://registry.npmjs.org/mime/1.2.5
npm http 304 https://registry.npmjs.org/node-uuid/1.3.3
npm http 304 https://registry.npmjs.org/dtrace-provider/0.0.9
npm http 304 https://registry.npmjs.org/qs/0.5.0
npm http 304 https://registry.npmjs.org/semver/1.0.14
npm http 200 https://registry.npmjs.org/retry/-/retry-0.6.0.tgz
npm http 304 https://registry.npmjs.org/formidable/1.0.11
npm http GET https://registry.npmjs.org/ctype/0.5.0
npm http GET https://registry.npmjs.org/asn1/0.1.11

> dtrace-provider@0.0.9 install E:\Dev_Root\freelance\Elance\projects\GordonHo\node.js\restify\node_modules\restify\node
_modules\dtrace-provider
> node-waf clean ; node-waf configure build

'node-waf' 不是内部或外部命令,也不是可运行的程序
或批处理文件。
npm WARN optional dep failed, continuing dtrace-provider@0.0.9
npm http 304 https://registry.npmjs.org/asn1/0.1.11
npm http 304 https://registry.npmjs.org/ctype/0.5.0
restify@1.4.4 node_modules\restify
├── byline@2.0.2
├── lru-cache@1.1.0
├── semver@1.0.14
├── retry@0.6.0
├── mime@1.2.5
├── async@0.1.22
├── node-uuid@1.3.3
├── qs@0.5.0
├── bunyan@0.10.0
├── formidable@1.0.11
└── http-signature@0.9.9 (asn1@0.1.11, ctype@0.5.0)

然后后来去运行

curl -is http://localhost:8080/hello/mark -H ‘accept: text/plain’

结果任何输出也没有。

后来通过浏览器验证,访问:

http://localhost:8080/hello/mark

是OK的。

说明服务器是好的。

而cygwin中的curl是有问题的。

所以就又去重新下载最新的cygwin的setup.exe,重新安装cygwin中的curl。

后来就是一堆的折腾,最终还是没搞定,结果以重新安装cygwin收场。。。

 

不过,后来,最后终于搞清楚了。

【总结】

貌似通过npm安装某个模块后,对应的运行某个js文件的话,需要在当前文件夹下运行,否则就会出现找不到模块的问题。

并且试了,即使在node.js的安装目录下去用npm安装,也都是没用的

转载请注明:在路上 » 【已解决】npm install之后,结果也还是会出现 can not find module的错误

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

网友最新评论 (1)

  1. 和LL遇到一样的问题了,必须在运行的模块下使用,不然一直报错
    cy4年前 (2016-01-27)回复
65 queries in 0.131 seconds, using 18.84MB memory