# Use a manually installed node in a Function node?

**URL:** <https://discourse.nodered.org/t/use-a-manually-installed-node-in-a-function-node/78104>\
**Category:** General\
**Created:** [2 May 2023 12:56 UTC](https://discourse.nodered.org/t/use-a-manually-installed-node-in-a-function-node/78104 "2023-05-02T12:56:17Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![SuperNinja](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/superninja/32/5761_2.png) [@SuperNinja](https://discourse.nodered.org/u/SuperNinja)\
**Post date:** [2 May 2023 12:56 UTC](https://discourse.nodered.org/t/use-a-manually-installed-node-in-a-function-node/78104/1 "2023-05-02T12:56:18Z")

</div>

Hi,  
I am looking to translate text. Like many I installed the `node-red-contrib-google-translate` node with the Palette.  
Then I wanted to go further and translate text into a Function node.  
I found `@vitalets/google-translate-api`.  
I was going to install it with npm, but first, out of curiosity, and because google-translate is already installed in the Palette, I went to my `node_modules` folder and saw that `@vitalets/google-translate-api` is already installed (you call it a dependency I think?)

**My question:** how can I use this module to translate text in a Function node?

In the Github of `@vitalets/google-translate-api` he describes a use with node.js:

```auto
import { translate } from '@vitalets/google-translate-api';
const { text } = await translate('Привет, мир! Как дела?', { to: 'en' });
console.log(text) // => 'Hello World! How are you?'

```

_I replace `console.log(text)` by `node.warn(text)`_ But that's not enough 😆

so I ran into an alert: `SyntaxError: Cannot use import statement outside a module (body:line 2)`

Is there a setting to add in settings.js ? or another line of javascript code to change in my Function? (It may help me in the future, when I install other modules manually)

---

<div class="post-metadata">

**Author:** ![cameo69](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cameo69/32/66593_2.png) [@cameo69](https://discourse.nodered.org/u/cameo69)\
**Post date:** [2 May 2023 13:30 UTC](https://discourse.nodered.org/t/use-a-manually-installed-node-in-a-function-node/78104/2 "2023-05-02T13:30:41Z")

</div>

You can define it on the setup tab of the function.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/1/91faceeea2dad14a2ea6e200618f676603017485.png)

Then use code:

```auto
//import { translate } from '@vitalets/google-translate-api';
const text = await translate_api.translate ('Привет, мир! Как дела?', { to: 'en' });
console.log(text) // => 'Hello World! How are you?'
msg.payload = text;
return msg;

```

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/7/07a8453873d862bd3ed15199b28755291e303ba7.png)

```auto
[{"id":"7f41b7600903dcec","type":"inject","z":"31db2d7b1f86fabe","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":840,"y":120,"wires":[["b7e5e1dfedfd757a"]]},{"id":"0e3bc3f4aa7f06db","type":"debug","z":"31db2d7b1f86fabe","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1230,"y":120,"wires":[]},{"id":"b7e5e1dfedfd757a","type":"function","z":"31db2d7b1f86fabe","name":"","func":"//import { translate } from '@vitalets/google-translate-api';\nconst text = await translate_api.translate ('Привет, мир! Как дела?', { to: 'en' });\nconsole.log(text) // => 'Hello World! How are you?'\nmsg.payload = text;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[{"var":"translate_api","module":"@vitalets/google-translate-api"}],"x":1020,"y":120,"wires":[["0e3bc3f4aa7f06db"]]},{"id":"c657668bfffb92d7","type":"comment","z":"31db2d7b1f86fabe","name":"https://discourse.nodered.org/t/use-a-manually-installed-node-in-a-function-node/78104","info":"https://discourse.nodered.org/t/use-a-manually-installed-node-in-a-function-node/78104","x":1030,"y":60,"wires":[]}]

```

---

<div class="post-metadata">

**Author:** ![SuperNinja](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/superninja/32/5761_2.png) [@SuperNinja](https://discourse.nodered.org/u/SuperNinja)\
**Post date:** [3 May 2023 08:13 UTC](https://discourse.nodered.org/t/use-a-manually-installed-node-in-a-function-node/78104/3 "2023-05-03T08:13:12Z")

</div>

Great it works! THANKS

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [17 May 2023 08:13 UTC](https://discourse.nodered.org/t/use-a-manually-installed-node-in-a-function-node/78104/4 "2023-05-17T08:13:50Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
