javascript - "module fs cannot be found" - Stack Overflow

i have used var module = require('pathtonode_modulesmodule-name') and all of my other mod

i have used var module = require('/path/to/node_modules/module-name') and all of my other models get recognized but fs does not get recognized even though I've pointed to where it is and made sure that its installed?? i do not understand, please help

my console gives out this:

but all my other modules are fine

as you can see by my referencing:

i have used var module = require('/path/to/node_modules/module-name') and all of my other models get recognized but fs does not get recognized even though I've pointed to where it is and made sure that its installed?? i do not understand, please help

my console gives out this: http://prntscr./g2akvs

but all my other modules are fine

as you can see by my referencing: http://prntscr./g2akzm

Share edited Jul 31, 2017 at 0:54 Louis 152k28 gold badges286 silver badges329 bronze badges asked Jul 30, 2017 at 23:00 Ben WallBen Wall 772 silver badges9 bronze badges 9
  • 2 fs is a native nodejs module, it sould be imported as is: let fs = require('fs'); – alexmac Commented Jul 30, 2017 at 23:04
  • tried it but it doesnt work :/ – Ben Wall Commented Jul 30, 2017 at 23:06
  • The same error? – alexmac Commented Jul 30, 2017 at 23:07
  • yes it does, i had to remove the file path and change it to just ('fs') – Ben Wall Commented Jul 30, 2017 at 23:07
  • i mean to say it about working* – Ben Wall Commented Jul 30, 2017 at 23:08
 |  Show 4 more ments

1 Answer 1

Reset to default 5

In node.js, fs is a native, built-in module. You include it without any path as in:

const fs = require('fs');

Here's the list of built-in libs from the node.js source:

const builtinLibs = [
  'assert', 'async_hooks', 'buffer', 'child_process', 'cluster', 'crypto',
  'dgram', 'dns', 'domain', 'events', 'fs', 'http', 'https', 'net', 'os',
  'path', 'punycode', 'querystring', 'readline', 'repl', 'stream',
  'string_decoder', 'tls', 'tty', 'url', 'util', 'v8', 'vm', 'zlib'
];

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745057348a4608748.html

相关推荐

  • javascript - "module fs cannot be found" - Stack Overflow

    i have used var module = require('pathtonode_modulesmodule-name') and all of my other mod

    20小时前
    40

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信