[英]node.js on heroku: Error: Cannot find module 'csv'
I'm using a common node package 'csv' to do CSV parsing. 我正在使用公共节点包'csv'来进行CSV解析。 It works great on my local mac, but not on heroku. 它在我的本地mac上工作得很好,但在heroku上却不行。 In the "heroku log", I get Cannot find module 'csv' . 在“heroku日志”中,我得到了无法找到模块'csv' 。
Yes, I have it in my package json file: 是的,我在我的包json文件中有它:
{
"name":"rimes",
"version":"0.0.1",
"dependencies":{
"sys":"",
"url":"",
"http":"",
"querystring":"",
"oauth":"0.9.10",
"fs":"",
"csv":"0.3.0",
"request":"",
"node-cache":"",
"underscore":""
}
}
and I require it in my app.js 我在app.js中要求它
var sys = require('sys'),
http = require('http'),
url = require('url'),
qs = require('querystring'),
OAuth= require('oauth').OAuth,
fs = require('fs'),
csv = require('csv'),
myreq = require('request'),
NodeCache = require('node-cache'),
us = require('underscore');
What can I do to fix this on heroku? 我该怎么做才能在heroku上解决这个问题?
Thank you, ~Todd 谢谢,〜托德
So when you require packages on node, you also need to install them in your node_modules folder. 因此,当您需要节点上的包时,还需要将它们安装在node_modules文件夹中。 They must be in the node_modules folder as well as "required" in your code. 它们必须位于node_modules文件夹中,并且必须位于代码中的“required”。 They can only be declared in your "package.json." 它们只能在“package.json”中声明。
If you go into your project directory (the file where package.json is located) and run: 如果你进入你的项目目录(package.json所在的文件)并运行:
npm install
it should install your missing dependencies into your 'node_modules' folder. 它应该将您缺少的依赖项安装到“node_modules”文件夹中。
Then if you re-deploy your app to heroku it should work. 然后,如果您将应用程序重新部署到heroku,它应该可以正常工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.