using node modules

Dmitry D. shared this question 7 years ago
Answered

Hello.

Similarly this

npm install json2csv -g

and then in mongobooster

varjson2csv = require('json2csv');

I try to do

npm install request -g

var rq = require('request');

and get the error

{

"code": "MODULE_NOT_FOUND",

"message": "Cannot find module 'request'",

"stack": "script:1:10"

}


Please, help to solve this problem.

With best regards,

Dmitry.

Replies (3)

photo
1

You don't need to install npm modules globally. You can install npm modules to your user data directory.

1. Main Menu -> Help -> Open User Data Directory

2. Righ-click menu: New Terminal at Folder https://tinyurl.com/kv9b5m2

3. run: > npm i request-promise ;//or request, you have to promisify it later.


  1. var rp = require('request-promise');
  2. await(rp('https://www.bing.com'))


4568e58b2a25be19a3b4fa97c1ddfe7e

photo
1

Thank you very much!

photo
1

Hello,


I've installed the timespan node module in my MongoBooster user data directory, and it seems to be installed.


  1. npm list
  2. +-- moment@2.18.1
  3. +-- node-fetch@1.6.3
  4. | +-- encoding@0.1.12
  5. | | `-- iconv-lite@0.4.17
  6. | `-- is-stream@1.1.0
  7. `-- timespan@2.3.0


However, when I try to use it in MongoBooster I get the following error:


{

"message" : "Cannot find module 'timespan'",

"stack" : "script:1:16",

"code" : "MODULE_NOT_FOUND"

}


Here's how I'm requiring the module:


  1. var timespan = require('timespan');
  2. var ts = new timespan.TimeSpan();


Any suggestions?


Thanks,

Jeff

photo
1

There may be a problem with the node_modules path resolution.

Please open a terminal at MongoBooster user data directory, and run "npm init"


  1. > npm init -y

try it again.

photo
1

It's working now. Thank you!!

photo
1

Huh, this didn't work for me. I'm trying to perform an export (from the menu) of a query to a CSV file and the import of "fs" is not working:


```

{

"message" : "Cannot find module '/Users/craig-mbp/Library/Application Support/NoSQLBooster for MongoDB/node_modules/fs'",

"stack" : "script:2:1",

"code" : "MODULE_NOT_FOUND"

}

```


Here's what's installed:


```

NoSQLBooster for MongoDB$ npm list

mongobooster-user-module@0.1.0 /Users/craig-mbp/Library/Application Support/NoSQLBooster for MongoDB

├── chance@1.0.13

├── fs@0.0.1-security

├── long@3.2.0

├─┬ meteor-random@0.0.3

│ └── crypto@0.0.3

└─┬ mongodb@2.2.31

├── es6-promise@3.2.1

├─┬ mongodb-core@2.1.15

│ ├── bson@1.0.4

│ └─┬ require_optional@1.0.1

│ ├── resolve-from@2.0.0

│ └── semver@5.4.1

└─┬ readable-stream@2.2.7

├── buffer-shims@1.0.0

├── core-util-is@1.0.2

├── inherits@2.0.3

├── isarray@1.0.0

├── process-nextick-args@1.0.7

├─┬ string_decoder@1.0.3

│ └── safe-buffer@5.1.1

└── util-deprecate@1.0.2

```


I did a `npm init -y` to rebuild and still get the same error and restarted nosqlbooster and still doesn't work. Any ideas how to fix this?


Craig

photo
2

I noticed that there is a "fs@0.0.1-security" module in your module list. It conflicts with the nosqlbooster's built-in fs module and you have to delete it and try again.

photo
1

Yup, that fixed it. Thank you!!

photo
1

Main Menu -> Help -> Open User Data Directory does nothing to me, not even print errors to console.


I'm running nosqlbooster Version 5.2.5 on Linux Mint 19.2

photo
Leave a Comment
 
Attach a file