最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Node.js: "Access is denied" - Stack Overflow

programmeradmin1浏览0评论

I'm trying to make a simple node.js app in VS Code. All im trying to do is:

const name = "Tom";
console.log("Hello " + name);

When I run the code, I get the error: Program 'node.exe' failed to run: Access is denied. When I try to check Node is installed with node -v in windows cmd, it also says "Access is denied". How do I fix this issue?

I'm trying to make a simple node.js app in VS Code. All im trying to do is:

const name = "Tom";
console.log("Hello " + name);

When I run the code, I get the error: Program 'node.exe' failed to run: Access is denied. When I try to check Node is installed with node -v in windows cmd, it also says "Access is denied". How do I fix this issue?

Share Improve this question asked Aug 20, 2020 at 14:52 RtHAitP30DRtHAitP30D 3263 gold badges8 silver badges20 bronze badges 2
  • Check if the node is registered on system environment variables. – Derek Wang Commented Aug 20, 2020 at 14:59
  • 1 I don't that's the issue as with environment variables issue it generally throws error node is not found as external or internal mand – Shivam Commented Aug 20, 2020 at 15:00
Add a ment  | 

6 Answers 6

Reset to default 2

You don't have enough permission to execute node mands in CMD, to solve this

Run CMD as an Admin

  1. Type cmd on your start menu

  2. Right click on the "Command Prompt" menu item and select "Open file Location"

  3. Right click on the file and select properties.

  4. Go to "Advanced" and select "Run as Administrator" and Ok.

If this doesn't solve your problem -

  1. Go to the "Security" tab.

  2. Click "Edit"

  3. Add "Everyone" and Ok

The fastest way that worked for me (Windows 10) was the following:

  1. Open "nodejs" folder location
  2. Right-click + R
  3. Open "Security tab" + "Advanced"
  4. Change Owner to "Administrator".
  5. Add permissions for Administrator "Full control"
  6. Tick "Replace all child objects permission entries..."
  7. "Ok". Save

✅ Done

use mand prompt instead of powershell in windows 10

In my case I was using NVM and in admin mode CMD when I selected version nvm list and nvm use version_goes_here and did npm i and it worked like a charm I hope it helped you or anyone reading this. :)

Add "cd" before your directory name in cmd.

Ex: cd C:\Users..\js folder name(not the filename)

and then type "dir" in cmd.

Ex: dir

you will get a list of files present in that folder,And then just enter "node jsfilename"

[Ex][2]: node jsfilename

now you will have the desired output in cmd.

I think Access Denied happened because your root directory was different than the file's root directory that's why we used "cd" change directory, and to view the files present in the current directory we used "dir". Then we opened the js file with node "node jsfilename".I hope You Got it.I believe you can see the image I have Attached below.

Refer To this image below:
https://i.sstatic/oibrF.jpg

发布评论

评论列表(0)

  1. 暂无评论