create new npm project code example
Example 1: npm default init
npm config ls -l # List some default settings
npm config set <key> <value> -g # Set default value for a key
npm config set init-author-name "John Doe" -g # Set default author
npm config set init-version "1.0.0" -g # Set default version
npm config set init-license "MIT" -g # Set default license
npm config get <key> # Get default value for a key
npm init -y # Create package.json with default settings
Example 2: how to create npm project
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}/`);
});