简体   繁体   English

heroku上的node.js:错误:找不到模块'csv'

[英]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.

相关问题 错误:在Heroku的node.js上找不到模块'jquery' - Error: Cannot find module 'jquery' on node.js on Heroku node.js:错误:找不到模块 - node.js: Error: Cannot find module 在Heroku上找不到模块'ejs' - Node.js应用程序 - Cannot find module 'ejs' - Node.js app on Heroku 使用node.js在Heroku中找不到模块'Parse' - Cannot find module 'Parse' in Heroku using node.js 将 node.js 应用程序部署到 heroku 时出错(找不到模块 dotenv 和 npm ERR!errno 1) - Error while deploying node.js application to heroku (cannot find module dotenv, and npm ERR! errno 1) 在Heroku或RedHat Openshift Online上部署node.js程序时出现“找不到模块”错误消息 - “Cannot find module” error message when deploying a node.js program on Heroku or RedHat Openshift Online 在 Heroku 上部署 Node.js 应用程序在本地成功,但显示错误:无法在线找到模块“/应用程序/服务器” - Deploying Node.js app on Heroku successful on locally but shows Error: Cannot find module '/app/server' online Node.js mailparser模块错误:找不到模块'iconv' - Node.js mailparser module error: Cannot find module 'iconv' Node.js 错误错误:找不到模块“bluebird” - Node.js ERROR Error: Cannot find module 'bluebird' Node.js 错误错误:找不到模块“猫鼬” - Node.js error Error: Cannot find module 'mongoose'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM