# Importing Package

**URL:** <https://discourse.nodered.org/t/importing-package/9900>\
**Category:** General\
**Created:** [8 April 2019 13:19 UTC](https://discourse.nodered.org/t/importing-package/9900 "2019-04-08T13:19:00Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![Trainocate](https://avatars.discourse-cdn.com/v4/letter/t/4da419/32.png) [@Trainocate](https://discourse.nodered.org/u/Trainocate)\
**Post date:** [8 April 2019 13:19 UTC](https://discourse.nodered.org/t/importing-package/9900/1 "2019-04-08T13:19:00Z")

</div>

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/2/200bc8550a3c490f8f9ae66d5ca8c97af8f621ea.png)  
When i tried to run this code in function node i get an error as ""ReferenceError: require is not defined ", please guide us How to use 'Request' Package in Node-red environment?

---

<div class="post-metadata">

**Author:** ![ukmoose](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ukmoose/32/13_2.png) [@ukmoose](https://discourse.nodered.org/u/ukmoose)\
**Post date:** [8 April 2019 13:23 UTC](https://discourse.nodered.org/t/importing-package/9900/2 "2019-04-08T13:23:02Z")

</div>

See the **Node Configuration** part of the docs [https://nodered.org/docs/configuration](https://nodered.org/docs/configuration)

You can "require" it within the Node-RED settings file and then "get" it from the function node

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [8 April 2019 13:30 UTC](https://discourse.nodered.org/t/importing-package/9900/3 "2019-04-08T13:30:54Z")

</div>

But seeing as the code you are sharing looks like an http request - why not use the built in http-request node ?

---

<div class="post-metadata">

**Author:** ![Trainocate](https://avatars.discourse-cdn.com/v4/letter/t/4da419/32.png) [@Trainocate](https://discourse.nodered.org/u/Trainocate)\
**Post date:** [9 April 2019 04:19 UTC](https://discourse.nodered.org/t/importing-package/9900/4 "2019-04-09T04:19:50Z")

</div>

Problem is i'm getting SSL3 handshake error while performing HTTP request. Hence using function node

---

<div class="post-metadata">

**Author:** ![Trainocate](https://avatars.discourse-cdn.com/v4/letter/t/4da419/32.png) [@Trainocate](https://discourse.nodered.org/u/Trainocate)\
**Post date:** [9 April 2019 06:28 UTC](https://discourse.nodered.org/t/importing-package/9900/5 "2019-04-09T06:28:37Z")

</div>

Can you please be more precise? if you don't mind

---

<div class="post-metadata">

**Author:** ![ukmoose](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ukmoose/32/13_2.png) [@ukmoose](https://discourse.nodered.org/u/ukmoose)\
**Post date:** [9 April 2019 06:39 UTC](https://discourse.nodered.org/t/importing-package/9900/6 "2019-04-09T06:39:56Z")

</div>

More precise than to read a specific part of the relevant page in the docs? Which bit don’t you understand?

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [9 April 2019 06:50 UTC](https://discourse.nodered.org/t/importing-package/9900/7 "2019-04-09T06:50:42Z")

</div>

This is the section of the docs that explain how to load extra modules in the node: [https://nodered.org/docs/writing-functions#loading-additional-modules](https://nodered.org/docs/writing-functions#loading-additional-modules)

---

<div class="post-metadata">

**Author:** ![Trainocate](https://avatars.discourse-cdn.com/v4/letter/t/4da419/32.png) [@Trainocate](https://discourse.nodered.org/u/Trainocate)\
**Post date:** [9 April 2019 07:03 UTC](https://discourse.nodered.org/t/importing-package/9900/8 "2019-04-09T07:03:25Z")

</div>

Upon reading the documentation it is suppose to get implemented in Terminal but how shall i do this  
"cd ~/.node-red  
npm install name\_of\_3rd\_party\_module" in cloud environment?

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [9 April 2019 07:04 UTC](https://discourse.nodered.org/t/importing-package/9900/9 "2019-04-09T07:04:50Z")

</div>

Which cloud environment?

---

<div class="post-metadata">

**Author:** ![Trainocate](https://avatars.discourse-cdn.com/v4/letter/t/4da419/32.png) [@Trainocate](https://discourse.nodered.org/u/Trainocate)\
**Post date:** [9 April 2019 07:06 UTC](https://discourse.nodered.org/t/importing-package/9900/10 "2019-04-09T07:06:33Z")

</div>

from node-red in bluemix!

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [9 April 2019 07:43 UTC](https://discourse.nodered.org/t/importing-package/9900/11 "2019-04-09T07:43:58Z")

</div>

Hi @Trainocate

You'll need to edit your application's `package.json` file and add any additional modules you want into its `package.json`'s dependencies section.

In order to edit the file, you must enable the Continuous Delivery integration option via your application’s IBM Cloud dashboard page. That will create a git repository on either GitHub or IBM DevOps services, from where you can edit the file, save the changes and push back into the cloud.

Nick

---

<div class="post-metadata">

**Author:** ![Trainocate](https://avatars.discourse-cdn.com/v4/letter/t/4da419/32.png) [@Trainocate](https://discourse.nodered.org/u/Trainocate)\
**Post date:** [9 April 2019 11:26 UTC](https://discourse.nodered.org/t/importing-package/9900/12 "2019-04-09T11:26:24Z")

</div>

Followed your instructions, in order to prevent the error "Require is not defined" which module am I suppose to add and how additional modules can be added in dependencies section  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/2/2443ad9b92307798d07705aef80796af4d15cbc5.png)

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [9 April 2019 13:42 UTC](https://discourse.nodered.org/t/importing-package/9900/13 "2019-04-09T13:42:19Z")

</div>

@Trainocate As the docs explain here: [https://nodered.org/docs/writing-functions#loading-additional-modules](https://nodered.org/docs/writing-functions#loading-additional-modules) you don't use `require` in your function node.

> [@Trainocate](#):
>
> which module am I suppose to add

Your code uses the `request` module - I assume you'd want to add that to the dependencies section. Once you've done that, you can edit `bluemix-settings.js` and add an entry in `functionGlobalContext` for the module - just as the documentation describes.

---

<div class="post-metadata">

**Author:** ![Trainocate](https://avatars.discourse-cdn.com/v4/letter/t/4da419/32.png) [@Trainocate](https://discourse.nodered.org/u/Trainocate)\
**Post date:** [10 April 2019 05:12 UTC](https://discourse.nodered.org/t/importing-package/9900/14 "2019-04-10T05:12:47Z")

</div>

Yes 'Request' module is the one which I will have to use in my code, but referring the link "[https://nodered.org/docs/writing-functions#loading-additional-modules](https://nodered.org/docs/writing-functions#loading-additional-modules)" it says that i should add modules in _settings.js_ file. Kindly guide us how to add it exactly inside the dependencies section.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [10 April 2019 08:17 UTC](https://discourse.nodered.org/t/importing-package/9900/15 "2019-04-10T08:17:45Z")

</div>

The example you linked to shows how to use the `os` module. Just replace `os` with whichever module you want to use.

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [10 April 2019 08:21 UTC](https://discourse.nodered.org/t/importing-package/9900/16 "2019-04-10T08:21:47Z")

</div>

@colin - os is built into node.js... external packages will also need to be added to your `packages.json` file - something like `"request": "^2.88.1",` in the dependencies section. You many not need the trailing comma t the end if it is the last one in the list.

---

<div class="post-metadata">

**Author:** ![Trainocate](https://avatars.discourse-cdn.com/v4/letter/t/4da419/32.png) [@Trainocate](https://discourse.nodered.org/u/Trainocate)\
**Post date:** [10 April 2019 10:55 UTC](https://discourse.nodered.org/t/importing-package/9900/17 "2019-04-10T10:55:53Z")

</div>

Followed the instructions and deployed the project into IBM cloud but getting this message!

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/1/1df333e9ca19bb531df757f4073e2f804489bb6a.png)
