... oprócz wiedzy.
Widzę że jakiegoś modułu, ale jak go dodać? Piszę pierwszy skrypt do uruchomienia serwera z książki "Podręcznik node.js":
var http = require('http');
var serv = http.createServer(function (reg, res){
res.writeHead(200, {'Content-Type': 'text/html; charset=utf-8'});
res.end('<marquee>Podrêcznik Node!</marquee>');
});
serv.listen(3000);
kiedy chce uruchomić $node my-web-server.js
wywala błąd:
# node my-web-server.js
internal/modules/cjs/loader.js:573
throw err;
^
Error: Cannot find module '/home/qn_x/www/node/my-web-server.js'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:571:15)
at Function.Module._load (internal/modules/cjs/loader.js:497:25)
at Function.Module.runMain (internal/modules/cjs/loader.js:719:10)
at startup (internal/bootstrap/node.js:228:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:576:3)
...
Robię kolejny przykład. Instaluje npm install colors. Wszystko się zainstalował. Tworze plik index.js:
require('colors');
console.log('podręcznik node'.rainbow);
i kolejny błąd.
node index.js
internal/modules/cjs/loader.js:573
throw err;
^
Error: Cannot find module 'colors'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:571:15)
at Function.Module._load (internal/modules/cjs/loader.js:497:25)
at Module.require (internal/modules/cjs/loader.js:626:17)
at require (internal/modules/cjs/helpers.js:20:18)
at Object.<anonymous> (/home/qn_x/www/node/index.js:1:63)
at Module._compile (internal/modules/cjs/loader.js:678:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:689:10)
at Module.load (internal/modules/cjs/loader.js:589:32)
at tryModuleLoad (internal/modules/cjs/loader.js:528:12)
at Function.Module._load (internal/modules/cjs/loader.js:520:3)
Proszę o sugestie. Dopiero zaczynam node, więc proszę o wyrozumiałość. Z góry serdecznie dziękuję za pomoc.