micheleriva / the-quotes-database

The repository containing the code for the "Fulltext search with ElasticSearch and Node on Docker" article
https://micheleriva.medium.com/full-text-search-with-node-js-and-elasticsearch-on-docker-edcea23612fd
MIT License
45 stars 33 forks source link

npm ERR! path /package.json #2

Open theZulqarnain opened 2 years ago

theZulqarnain commented 2 years ago

tqd-node | npm ERR! path /package.json tqd-node | npm ERR! code ENOENT tqd-node | npm ERR! errno -2 tqd-node | npm ERR! syscall open tqd-node | npm ERR! enoent ENOENT: no such file or directory, open '/package.json' tqd-node | npm ERR! enoent This is related to npm not being able to find a file. tqd-node | npm ERR! enoent tqd-node | tqd-node | npm ERR! A complete log of this run can be found in: tqd-node | npm ERR! /root/.npm/_logs/2021-11-30T15_57_13_712Z-debug.log tqd-node exited with code 254

micheleriva commented 2 years ago

may I have some context?

theZulqarnain commented 2 years ago

on cammand sudo docker-compose up its show the above error.

made some changes on dockerfile like COPY ./package*.json . package*.json. didn't work.

theZulqarnain commented 2 years ago

any update please...

ritikbanger commented 2 years ago

@theZulqarnain I am facing the same issue. Did you find any solution?

Bhagyashreek15 commented 2 years ago

I have faced same issue and also found solution. Change docker-compose file and data->index.js its worked for me.

docker-compose.yml

version: '3'

services: api: # Node.js App container_name: tqd-node2 build: . ports:

volumes: # Define seperate volume for Elasticsearch data esdata:

index.js const elastic = require("../elastic"); const quotes = require("./quotes.json");

const esAction = { index: { _index: elastic.index, _type: elastic.type } }; [ { index: { _index: elastic.index, _type: elastic.type } }, { author: "quote author", quote: "quote" }

] async function populateDatabase() { const docs = []; for (const quote of quotes) { docs.push(esAction); docs.push(quote); } return elastic.esclient.bulk({ body: docs }); } populateDatabase() console.log("data inserted");