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
1 Answer
Reset to default 5In 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
评论列表(0条)