adaltas / adaltas/node-csv

Error parsing triggers: Cannot find module 'csv-parse/sync'

Open
#323 26 comments 13 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
4.3k
Forks
299
Avg merge
16h 19m
Merged PRs (30d)
1

Description

Describe the bug

When I try to use csv-parse/sync instead of csv-parse, my deploy to Firebase Functions fail with the following error:

Error: Error parsing triggers: Cannot find module 'csv-parse/sync''
Require stack:
- /Users/xxx/Programming/xxx/Firebase Functions/xxx/functions/lib/index.js
- /usr/local/lib/node_modules/firebase-tools/lib/deploy/functions/runtimes/node/triggerParser.js

Try running "npm install" in your functions directory before deploying.

To Reproduce

Import using:

import { parse } from 'csv-parse/sync';

Then use in code like this:

interface EventData {
	update: string;
	id: string;
	title: string;
	description: string;
	category: string;
	ages: string;
	place: string;
	placeCoordinate: string;
	startDate: string;
	startTime: string;
	length: string;
	url: string;
	arrName: string;
  }


let events: Array<EventData> = []
const headers = ["update", "id", "title", "description", "ages", "place", "placeCoordinate", "startDate", "startTime", "length", "url", "arrEpost", "arrName", "validated", "skugg"]
try {
    events = parse(text, {columns: headers, from: 6, quote: "\"", delimiter: ";", ltrim: true, rtrim: true})
}...


I have installed by going to /functions-folder and running

npm install --save csv-parse

Deploying in root folder with

firebase deploy

Additional context

Is this an issue with the framework, with firebase or am I doing something wrong? Normal use of "csv-parse" without sync works just fine.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the import and deployment from the functions directory, using functions/lib/index.js and the triggerParser.js stack trace as the entry points. Check how csv-parse/sync is installed and resolved during Firebase Functions deployment; done means the documented import deploys successfully without the module-not-found error.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, nodejs
Domain
backend, cloud
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.