提问者:小点点

面对错误:运行Node js server时找不到模块“C:\Users\Dell\DesktoP\Node js Programs\File”


``

这是我运行节点js文件系统的代码


    var http = require('http');
    var fs = require('fs');
    http.createServer(function (req, res) {
      //Open a file on the server and return its content:
      fs.readFile('demofile1.html', function(err, data) {
        res.writeHead(200, {'Content-Type': 'text/html'});
        res.write(data);
        return res.end();
     
 });
    }).listen(3000);


``

> This is the error iam facing while running the code

内部/modules/cjs/loader.js:985抛出错误;^此处输入代码错误:在Function.module._resolveFileName(内部/module/cjs/loader.js:982:15)在Function.module._load(内部/module/cjs/loader.js:864:27)在Function.executeUserEntryPoint[作为runMain]({code:'module_not_found',requireStack:[]}


共1个答案

匿名用户

您的项目node_modules中有文件夹吗?

我怀疑你不知道。请在项目目录中运行NPM Install

相关问题