最新消息:20210816 当前crifan.com域名已被污染,为防止失联,请关注(页面右下角的)公众号

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

Node.js crifan 14550浏览 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

> [email protected] 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 [email protected]
npm http 304 https://registry.npmjs.org/asn1/0.1.11
npm http 304 https://registry.npmjs.org/ctype/0.5.0
[email protected] node_modules\restify
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
└── [email protected] ([email protected], [email protected])

然后后来去运行

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遇到一样的问题了,必须在运行的模块下使用,不然一直报错
    cy6年前 (2016-01-27)回复
92 queries in 0.134 seconds, using 20.68MB memory