caputomarcos / node-red-contrib-oauth2

The node-red-contrib-oauth2 is a Node-RED node that provides an OAuth2 authentication flow. This node uses the OAuth2 protocol to obtain an access token, which can be used to make authenticated API requests.
https://essavida.ai
MIT License
18 stars 17 forks source link

install on redmatic ccu3 failes #69

Open krilor1 opened 1 year ago

krilor1 commented 1 year ago

If i try to install oauth2 on redmatic in ccu3 i get the message "Cannot read property 'nodes' of null" and the node is not installed.

caputomarcos commented 1 year ago

@krilor1, could you please provide more information or a stack trace of the error? It would help in diagnosing the issue. Thank you.

krilor1 commented 1 year ago

Hello, unfortunately I don't get any more information.

caputomarcos commented 1 year ago

Hello @krilor1,

I'm sorry to hear that you're still experiencing issues. The error message "Cannot read property 'nodes' of null" is quite generic and could be caused by a variety of factors. It's a bit challenging to pinpoint the exact issue without more detailed information.

However, here are a few suggestions you might want to try:

If none of these suggestions help, please let me know. We'll continue to work on this issue together until we find a solution.

Best regards,

Caputo

caputomarcos commented 4 months ago

Hello @krilor1,

Thank you for your patience. I wanted to let you know that the latest version now includes support for RedMatic on CCU3. Please update to the newest version and try the installation again.

If you encounter any further issues or the problem persists, please feel free to reopen this issue. We're committed to ensuring that everything works smoothly for you.

Best regards,

Caputo

krilor1 commented 4 months ago

Hello, thank you for your answer. Unfortunately the installation does not work. I get this error: 2024-06-02T09:13:57.637Z [err] EBADENGINE 2024-06-02T09:13:57.637Z [err] required: { node: '>=16' }, 2024-06-02T09:13:57.637Z [err] npm 2024-06-02T09:13:57.638Z [err]
2024-06-02T09:13:57.638Z [err] WARN 2024-06-02T09:13:57.638Z [err]
2024-06-02T09:13:57.639Z [err] EBADENGINE 2024-06-02T09:13:57.639Z [err] current: { node: 'v14.16.0', npm: '7.6.3' } 2024-06-02T09:13:57.639Z [err] npm

Greetings, krilor1

caputomarcos commented 4 months ago

Hello @krilor1,

Thank you for informing me about the issue. Based on the information provided, the package node-red-contrib-oauth2 supports any Node.js version greater than or equal to 12.0.0, so version 14.16.0 should work correctly. The error messages might be caused by another configuration or dependency in your environment.

Here are some steps to resolve this:

  1. Check your Node.js and npm versions:

    node --version
    v14.16.0
    npm --version
    7.6.3
  2. Ensure you are in the correct directory and have all dependencies installed:

    cd ~/.node-red
    npm install
  3. Start Node-RED:

    node-red

Here is an example of how it was configured and succeeded in my environment:

~/.node-red
❯ node --version
v14.16.0
~/.node-red
❯ npm --version
7.6.3
~/.node-red
❯ node-red
3 Jun 09:53:54 - [info]

Welcome to Node-RED
===================

3 Jun 09:53:54 - [info] Node-RED version: v3.1.9
3 Jun 09:53:54 - [info] Node.js  version: v14.16.0
3 Jun 09:53:54 - [info] Linux 5.15.123.1-microsoft-standard-WSL2 x64 LE
3 Jun 09:53:54 - [info] Loading palette nodes
3 Jun 09:53:54 - [warn] Missing node modules:
3 Jun 09:53:54 - [warn]  - node-red-contrib-oauth2 (6.2.1): oauth2, oauth2
3 Jun 09:53:54 - [info] Removing modules from config
3 Jun 09:53:54 - [info] Settings file  : /home/caputo/.node-red/settings.js
3 Jun 09:53:54 - [info] Context store  : 'default' [module=memory]
3 Jun 09:53:54 - [info] User directory : /home/caputo/.node-red
3 Jun 09:53:54 - [warn] Projects disabled : editorTheme.projects.enabled=false
3 Jun 09:53:54 - [info] Flows file     : /home/caputo/.node-red/flows.json
3 Jun 09:53:54 - [warn]

---------------------------------------------------------------------
Your flow credentials file is encrypted using a system-generated key.

If the system-generated key is lost for any reason, your credentials
file will not be recoverable, you will have to delete it and re-enter
your credentials.

You should set your own key using the 'credentialSecret' option in
your settings file. Node-RED will then re-encrypt your credentials
file using your chosen key the next time you deploy a change.
---------------------------------------------------------------------

3 Jun 09:53:54 - [info] Waiting for missing types to be registered:
3 Jun 09:53:54 - [info]  - oauth2
3 Jun 09:53:54 - [info] Server now running at http://127.0.0.1:1880/
3 Jun 09:54:20 - [info] Installing module: node-red-contrib-oauth2, version: 6.2.1
3 Jun 09:54:22 - [info] Installed module: node-red-contrib-oauth2
3 Jun 09:54:22 - [info] Missing type registered: oauth2
3 Jun 09:54:22 - [info] Starting flows
3 Jun 09:54:22 - [info] Started flows
3 Jun 09:54:22 - [info] Added node types:
3 Jun 09:54:22 - [info]  - node-red-contrib-oauth2:oauth2
3 Jun 09:54:22 - [info]  - node-red-contrib-oauth2:oauth2

If the problem persists after these steps, please let me know so I can help investigate further.

Best regards,

Caputo.

krilor1 commented 4 months ago

Hello Caputo,the versions of my installation seem to be significantly lower than yours. Could this be a reason and can I simply change this?node --versionv8.11.4npm @. 03.06.2024 um 15:04 schrieb Marcos Caputo @.>: Hello @krilor1, Thank you for informing me about the issue. Based on the information provided, the package node-red-contrib-oauth2 supports any Node.js version greater than or equal to 12.0.0, so version 14.16.0 should work correctly. The error messages might be caused by another configuration or dependency in your environment. Here are some steps to resolve this:

Check your Node.js and npm versions: node --version v14.16.0 npm --version 7.6.3

Ensure you are in the correct directory and have all dependencies installed: cd ~/.node-red npm install

Start Node-RED: node-red

Here is an example of how it was configured and succeeded in my environment: ~/.node-red ❯ node --version v14.16.0 ~/.node-red ❯ npm --version 7.6.3 ~/.node-red ❯ node-red 3 Jun 09:53:54 - [info]

Welcome to Node-RED

3 Jun 09:53:54 - [info] Node-RED version: v3.1.9 3 Jun 09:53:54 - [info] Node.js version: v14.16.0 3 Jun 09:53:54 - [info] Linux 5.15.123.1-microsoft-standard-WSL2 x64 LE 3 Jun 09:53:54 - [info] Loading palette nodes 3 Jun 09:53:54 - [warn] Missing node modules: 3 Jun 09:53:54 - [warn] - node-red-contrib-oauth2 (6.2.1): oauth2, oauth2 3 Jun 09:53:54 - [info] Removing modules from config 3 Jun 09:53:54 - [info] Settings file : /home/caputo/.node-red/settings.js 3 Jun 09:53:54 - [info] Context store : 'default' [module=memory] 3 Jun 09:53:54 - [info] User directory : /home/caputo/.node-red 3 Jun 09:53:54 - [warn] Projects disabled : editorTheme.projects.enabled=false 3 Jun 09:53:54 - [info] Flows file : /home/caputo/.node-red/flows.json 3 Jun 09:53:54 - [warn]


Your flow credentials file is encrypted using a system-generated key.

If the system-generated key is lost for any reason, your credentials file will not be recoverable, you will have to delete it and re-enter your credentials.

You should set your own key using the 'credentialSecret' option in your settings file. Node-RED will then re-encrypt your credentials file using your chosen key the next time you deploy a change.

3 Jun 09:53:54 - [info] Waiting for missing types to be registered: 3 Jun 09:53:54 - [info] - oauth2 3 Jun 09:53:54 - [info] Server now running at http://127.0.0.1:1880/ 3 Jun 09:54:20 - [info] Installing module: node-red-contrib-oauth2, version: 6.2.1 3 Jun 09:54:22 - [info] Installed module: node-red-contrib-oauth2 3 Jun 09:54:22 - [info] Missing type registered: oauth2 3 Jun 09:54:22 - [info] Starting flows 3 Jun 09:54:22 - [info] Started flows 3 Jun 09:54:22 - [info] Added node types: 3 Jun 09:54:22 - [info] - node-red-contrib-oauth2:oauth2 3 Jun 09:54:22 - [info] - node-red-contrib-oauth2:oauth2 If the problem persists after these steps, please let me know so I can help investigate further. Best regards, Caputo.

—Reply to this email directly, view it on GitHub, bor unsubscribe.You are receiving this because you were mentioned.Message ID: @.***>

caputomarcos commented 4 months ago

Hello @krilor1,

Thank you for informing me about the issue. Based on the information provided, the node-red-contrib-oauth2 package supports any Node.js version greater than or equal to 12.0.0, so version 14.16.0 should work correctly. The error messages might be caused by another configuration or dependency in your environment.

Supported Node.js Versions by Node-RED

According to the Node-RED documentation (updated on 2024-01-03), it is currently recommended to use Node.js version 20.x. Node-RED aims to keep up with Node.js releases and supports the Maintenance and Active LTS versions. We do not recommend using the odd-numbered Node.js versions, as we do not routinely test against them.

Node-RED Version Minimum Node.js Version
4.x 18
3.x 14
2.x 12

Using nvm to Manage Node.js Versions

To address the difference in Node.js and npm versions, you can use Node Version Manager (nvm) to easily switch between different versions. Here’s how you can do it:

  1. Install nvm: If you don’t have nvm installed, you can install it by running the following command:

    curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash

    Then, add nvm to your shell profile by adding the following line to your .bashrc, .zshrc, or .profile:

    export NVM_DIR="$HOME/.nvm"
    [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
  2. Install the desired Node.js version: Once nvm is installed, you can install and use the desired Node.js version (e.g., 20.13.1):

    nvm install 20.13.1
    nvm use 20.13.1
  3. Verify the installation: Check your Node.js and npm versions to ensure they have been updated correctly:

    node --version
    npm --version
  4. Reinstall dependencies: Navigate to your Node-RED directory and reinstall your dependencies:

    cd ~/.node-red
    npm install
  5. Rebuild Dependencies: If you change the Node.js version you are using, you might need to rebuild Node-RED’s dependencies as well as any nodes you have installed. This is because some of them contain binary components that must be rebuilt to be compatible with the new Node.js version. This can be done using the npm rebuild command, but it must be run in the correct directory. There are two places where this should be run:

    • In your Node-RED user directory, ~/.node-red - this is where any additional nodes you have installed are.
    • In the directory where you installed Node-RED.
    npm rebuild
  6. Start Node-RED: Start Node-RED with the updated Node.js version:

    node-red

Example of Successful Configuration

Here is an example of how it was configured and succeeded in my environment:

~/.node-red
❯ node --version
v20.13.1
~/.node-red
❯ npm --version
7.6.3
~/.node-red
❯ node-red
4 Jun 13:46:15 - [info]

Welcome to Node-RED
===================

4 Jun 13:46:15 - [info] Node-RED version: v3.1.9
4 Jun 13:46:15 - [info] Node.js version: v20.13.1
4 Jun 13:46:15 - [info] Loading palette nodes
4 Jun 13:46:15 - [info] Settings file  : /home/krilor1/.node-red/settings.js
4 Jun 13:46:15 - [info] User directory : /home/krilor1/.node-red
4 Jun 13:46:15 - [info] Flows file     : /home/krilor1/.node-red/flows.json
4 Jun 13:46:15 - [info] Starting flows

Using nvm allows you to manage multiple versions of Node.js and switch between them as needed, making it easier to match the version requirements of different projects.

Best regards,

Caputo