LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   How To Set Node.js Extension PATH in VS Code (https://www.linuxquestions.org/questions/programming-9/how-to-set-node-js-extension-path-in-vs-code-4175720509/)

lattimro 01-04-2023 12:16 PM

How To Set Node.js Extension PATH in VS Code
 
1 Attachment(s)
Hi Folks,

I installed on a Slackware based (SALIX) VS Code via FlatPack and I tried to set up the JAVA environment. First time I tested a JavaScript sample file received a message (see attached).

Then I installed from package manager nodejs 17.9.0 and I
Code:

export PATH=$PATH:/usr/bin/node
Then I tried to add node.js extension.
I followed:
https://code.visualstudio.com/docs/n...ith-javascript

I tried to add to launch.json "runtimeExecutable": "node"

Code:

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "type": "node",
            "request": "launch",
            "name": "Launch Program",
            "skipFiles": [
                "<node_internals>/**"
            ],
            "program": "${workspaceFolder}/GettingStarted/jssample.js",
            "runtimeExecutable": "/usr/bin/node"
        }
    ]
}


but still got the same message.



Code:

brad@toshiba:~$ java -version
java version "19.0.1" 2022-10-18
Java(TM) SE Runtime Environment (build 19.0.1+10-21)
Java HotSpot(TM) 64-Bit Server VM (build 19.0.1+10-21, mixed mode, sharing)
brad@toshiba:~$ npm version
{
  npm: '8.5.5',
  node: '17.9.0',
  v8: '9.6.180.15-node.16',
  uv: '1.43.0',
  zlib: '1.2.12',
  brotli: '1.0.9',
  ares: '1.18.1',
  modules: '102',
  nghttp2: '1.47.0',
  napi: '8',
  llhttp: '6.0.4',
  openssl: '3.0.2+quic',
  cldr: '40.0',
  icu: '70.1',
  tz: '2021a3',
  unicode: '14.0',m
  ngtcp2: '0.1.0-DEV',
  nghttp3: '0.1.0-DEV'

Tried to install 19.3.0:

I can run the js file from CLI BUT not in VS Code environment.
Not to mention it works just fine on Debian based OSs.


Thanks!

dugan 01-04-2023 01:04 PM

If the setup works fine in Debian, then one option is to set up a Debian Docker to develop in.

NevemTeve 01-04-2023 01:45 PM

How is Java related to this problem?
Anyways, run this command, and insert here the result:
Code:

find / -name node -type f 2>/dev/null

dugan 01-04-2023 02:17 PM

Quote:

Originally Posted by lattimro (Post 6402204)
Then I installed from package manager nodejs 17.9.0 and I
Code:

export PATH=$PATH:/usr/bin/node

I think what NevemTeve is getting at is that Node might actually not be in your PATH. Your top post certainly has no evidence of you having confirmed that. Are you sure the above (which looks extremely strange) is right? If you think it is, then can you link to who it was who told you to do it?

lattimro 01-04-2023 03:22 PM

Quote:

Originally Posted by dugan (Post 6402230)
I think what NevemTeve is getting at is that Node might actually not be in your PATH. Your top post certainly has no evidence of you having confirmed that. Are you sure the above (which looks extremely strange) is right? If you think it is, then can you link to who it was who told you to do it?

what is strange?

who told you to do it?
To do what?

dugan 01-04-2023 04:36 PM

No, I’ll just be more direct.

What does “which node” print out?

lattimro 01-04-2023 04:45 PM

Quote:

Originally Posted by dugan (Post 6402250)
No, I’ll just be more direct.

What does “which node” print out?

does
Code:

npm version
I posted above mean anything?

dugan 01-04-2023 05:08 PM

Honestly, I didn’t see it because I didn’t read past the Java noise. It looks good.

VSCode has its own terminal. What do you see when you do that (“npm version”) from VSCode’s terminal? The one you can start from its Terminal menu.

lattimro 01-04-2023 06:53 PM

Quote:

Originally Posted by dugan (Post 6402256)
Honestly, I didn’t see it because I didn’t read past the Java noise. It looks good.

VSCode has its own terminal. What do you see when you do that (“npm version”) from VSCode’s terminal? The one you can start from its Terminal menu.

I see, thanks for the tips, unfortunately I can't ssh right now (magic does not work now), but for sure it will not see node. I need to let VSCode to know where node is and so far I can't find where to set the PATH.

later ...
just to confirm VSCode can't see outside its environment, which was predictible

lattimro 01-05-2023 09:20 AM

Quote:

Originally Posted by NevemTeve (Post 6402224)
How is Java related to this problem?
Anyways, run this command, and insert here the result:
Code:

find / -name node -type f 2>/dev/null

#7 means anything? I posted anyway:

Code:

/home/brad/Downloads/NODE.js/node-v18.12.1/out/Release/node
/home/brad/Downloads/NODE.js/node-v18.12.1-linux-x64/bin/node
/usr/bin/node
/proc/irq/0/node
/proc/irq/1/node
/proc/irq/2/node
/proc/irq/3/node
/proc/irq/4/node
/proc/irq/5/node
/proc/irq/6/node
/proc/irq/7/node
/proc/irq/8/node
/proc/irq/9/node
/proc/irq/10/node
/proc/irq/11/node
/proc/irq/12/node
/proc/irq/13/node
/proc/irq/14/node
/proc/irq/15/node
/proc/irq/16/node
/proc/irq/17/node
/proc/irq/19/node
/proc/irq/21/node
/proc/irq/23/node
/proc/irq/24/node
/proc/irq/25/node
/proc/irq/26/node
/proc/irq/27/node
/tmp/SBo/package-nodejs/usr/bin/node
/tmp/SBo/node-v19.3.0/out/Release/node


NevemTeve 01-05-2023 10:52 AM

/proc/ and /tmp/ shouldn't be important, examine the first three:
Code:

ls -ld /home/brad/Downloads/NODE.js/node-v18.12.1/out/Release/node \
/home/brad/Downloads/NODE.js/node-v18.12.1-linux-x64/bin/node \
/usr/bin/node

file /home/brad/Downloads/NODE.js/node-v18.12.1/out/Release/node \
/home/brad/Downloads/NODE.js/node-v18.12.1-linux-x64/bin/node \
/usr/bin/node


lattimro 01-05-2023 02:10 PM

Quote:

Originally Posted by NevemTeve (Post 6402393)
/proc/ and /tmp/ shouldn't be important, examine the first three:
Code:

ls -ld /home/brad/Downloads/NODE.js/node-v18.12.1/out/Release/node \
/home/brad/Downloads/NODE.js/node-v18.12.1-linux-x64/bin/node \
/usr/bin/node

file /home/brad/Downloads/NODE.js/node-v18.12.1/out/Release/node \
/home/brad/Downloads/NODE.js/node-v18.12.1-linux-x64/bin/node \
/usr/bin/node


I do not know what you want to get? It not about machi but VSCode not seeing node.js

first 2 in ~ are packages
the third:
Code:

root[brad]# ls -ld /usr/bin/node
-rwxr-xr-x 1 root root 72651768 May 27  2022 /usr/bin/node
root[brad]# file /usr/bin/node
/usr/bin/node: ELF 64-bit LSB executable, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, stripped


NevemTeve 01-05-2023 03:54 PM

Could you please explain this error message:
Can't find Node.js binary "node": path does not exist.
What path doesn't exist?

lattimro 01-05-2023 05:17 PM

Quote:

Originally Posted by NevemTeve (Post 6402462)
Could you please explain this error message:
Can't find Node.js binary "node": path does not exist.

What path doesn't exist?

That's the existential question, I'm glad you understand. If VS Code had found node.js, the OP wouldn't be here.

I assumed the PATH to node. The VS Code container can't communicate with the "node" on the machine.

I also tried almost all VSCode "node" extensions packages even they say:

Quote:

Visual Studio Code has support for the JavaScript and TypeScript languages out-of-the-box as well as Node.js debugging. However, to run a Node.js application, you will need to install the Node.js runtime on your machine.

To get started in this walkthrough, install Node.js for your platform. The Node Package Manager is included in the Node.js distribution. You'll need to open a new terminal (command prompt) for the node and npm command-line tools to be on your PATH.

To test that you have Node.js installed correctly on your computer, open a new terminal and type node --version and you should see the current Node.js version installed.
"You'll need to open a new terminal (command prompt) for the node and npm command-line tools to be on your PATH." What does mean?

NevemTeve 01-06-2023 12:31 AM

It might have a point: please quote the output of command /usr/bin/node --version


All times are GMT -5. The time now is 08:16 PM.