nodejs初学者安装教程 并在vscode里面使用

闲来无事下个nodejs玩

Node.js — 在任何地方运行 JavaScript

安装

Node.js安装教程及在vscode中的配置(超详细)_vscode nodejs-优快云博客

他的超详细我就不填了

然后到vscode部分 示例代码

const http = require('http');
 
const hostname = '127.0.0.1';
const port = 3000;
 
const server = http.createServer((req, res) => {
  res.statusCode = 200;
  res.setHeader('Content-Type', 'text/plain');
  res.end('Hello World\n');
});
 
server.listen(port, hostname, () => {
  console.log(`Server running at http://${hostname}:${port}/`);
});

vscode本人是新手,所以发现无法编译 并提示

"launch.json" 找不到 Node.js 二进制文件“node”: 路径不存在。请确保 Node.js 已安装且位于你的路径中,或者在 launch.json 中设置 "runtimeExecutable"在launch.json中加入即可。

然后打开 launch.json 设置

{
    "version": "0.2.0",
    "configurations": [
      {
        "type": "node",
        "request": "launch",
        "name": "Launch Program",
        "program": "${file}",
        "runtimeExecutable": "D:/Program Files/nodejs/node.exe"  // Windows 示例
        // "runtimeExecutable": "/usr/local/bin/node"            // macOS/Linux 示例
      }
    ]
  }

或者打开设置搜索 

  • 找到vscode 设置
  • 搜索 runtimeExecutable
  • 点击 editInSettings.json
"debug.javascript.defaultRuntimeExecutable": {
    "pwa-node": "D:/Program Files/nodejs/node.exe"
  }

层主当时都用了,发现还是不行,结果是因为盘符反了 蠢爆了

比如"D:\Program Files\nodejs\node.exe" 错误

不过也是完成hello,world了

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值