-1

So I'm trying to search google programmatically, and to do so i'm using the node module google-search-results-nodejs, but despite anything I do I keep getting the error not found. I'm working on gitpod online workspace. I wasn't sure if perhaps this had something to do with it but for the life of me I just can't figure it out, and I've looked elsewhere and can't find anything. I tried to check if perhaps my files were in the wrong location, tried uninstalling all node-modules folder and reinstalling it.

Any ideas

const SearchAPI = require('google-search-results-nodejs');
const search = new SearchAPI.GoogleSearchResults(
  "663185d5-API-KEY-76787e11787a9"
);

const params = {
  engine: 'google_reverse_image',
  image_url: 'https://i.imgur.com/E4cOSLw.jpg',
};

const cb = function (data) {
  console.log(data['inline-images']);
};

// here
search.json(params, cb);

Here's the error response:

gitpod /workspace/Copyright-Content-Removal/node_modules $ node app.js
internal/modules/cjs/loader.js:968
  throw err;
  ^

Error: Cannot find module '/workspace/Copyright-Content-Removal/node_modules/app.js'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:965:15)
    at Function.Module._load (internal/modules/cjs/loader.js:841:27)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
    at internal/main/run_main_module.js:17:47 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}

EDIT: Just retested it and am getting this https://ibb.co/YPBX5Y1 error message.... Also I attached a video link below

ArrSky76
  • 33
  • 4
  • Are you sure your file is called app.js? – germanescobar Oct 13 '20 at 05:52
  • are you importing this `app.js` file in any of your files? as I can see it is trying to fetch it from the `node_modules` folder which is weird. Try and give the right path/relative path if you are importing it. – kavigun Oct 13 '20 at 05:57
  • `gitpod /workspace/Copyright-Content-Removal/node_modules` `$ node app.js` you are starting your script wihint node_modules I think is probably one folder before `gitpod /workspace/Copyright-Content-Removal` `$ node app.js` – cperez08 Oct 13 '20 at 05:59
  • @kavigun not that I manually did, I never wrote import app.js anywhere.... I'm not importing it so I assume I shouldn't alter any path. Though I also assume I have to change it so that it stops looking for app.js in node_modules and rather starts looking for it where it should be in the root of the folder. – ArrSky76 Oct 13 '20 at 21:12

1 Answers1

0

Your app.js is inside node_modules directory -

/workspace/Copyright-Content-Removal/node_modules/app.js

But actually your app.js should be outside the node_modules directory like this -

/workspace/Copyright-Content-Removal/app.js
toyeca
  • 169
  • 2
  • 5
  • Hey thanks for the response, here is a video showing what I see.... Unforunately I don't see it in the node_modules folder, but I do agree something's a bit off about this. The only other thing I can think of is when we did npm init... we did something different with the entry point. Could it have anything to do with that. I think we either did app.js or rather index.js whichever is not the convention we did... Not sure if that has any impact on this problem. Here's the video: https://streamable.com/jmunvs – ArrSky76 Oct 13 '20 at 21:08
  • super super sorry I think I added the wrong error code! Here is the updated error code. https://ibb.co/YPBX5Y1 – ArrSky76 Oct 13 '20 at 21:15
  • Please ensure to install dependency "google-search-results-nodejs" - npm install google-search-results-nodejs – toyeca Oct 15 '20 at 15:03
  • I definitely did install that dependency – ArrSky76 Oct 16 '20 at 02:07