Go to directory of your project
mkdir TestProject cd TestProject
Make this directory a root of your project (this will create a default package.json
file)
npm init --yes
Install required npm module and save it as a project dependency (it will appear in package.json
)
npm install request --save
Create a test.js
file in project directory with code from package example
var request = require('request'); request('http://www.google.com', function (error, response, body) { if (!error && response.statusCode == 200) { console.log(body); // Print the google web page. } });
Your project directory should look like this
TestProject/ - node_modules/ - package.json - test.js
Now just run node inside your project directory
node test.js
Related Posts:
- CentOS error – sudo: effective uid is not 0, is sudo installed setuid root?
- How can I update NodeJS and NPM to the next versions?
- sudo: npm: command not found
- “Couldn’t find a file descriptor referring to the console” on Ubuntu bash on Windows
- curl: (6) Could not resolve host: google.com; Name or service not known
- npm update broke npm
- Gedit command not working in kali linux terminal
- How to open a “-” dashed filename using terminal?
- How do I deal with a filename that starts with the hyphen (-) character?
- Chmod 777 to a folder and all contents [duplicate]
- Bash: No such file or directory?
- How can I update npm itself?
- Cannot connect to the Docker daemon at unix:/var/run/docker.sock. Is the docker daemon running?
- How to install a previous exact version of a NPM package?
- Confused about stdin, stdout and stderr?
- How to solve npm error “npm ERR! code ELIFECYCLE”
- How to solve npm error “npm ERR! code ELIFECYCLE”
- What’s a .sh file?
- npm check and update package if needed
- Amazon Linux: apt-get: command not found
- How to set the environmental variable LD_LIBRARY_PATH in linux
- After command npm start “Missing script:start” error
- What’s a .sh file?
- How can I symlink a file in Linux? [closed]
- How to fix ‘sudo: no tty present and no askpass program specified’ error?
- Kill detached screen session [closed]
- How to resolve Nodejs: Error: ENOENT: no such file or directory
- How do I grep recursively?
- How do I grep recursively?
- How do I completely uninstall Node.js, and reinstall from beginning (Mac OS X)
- Why do you need to put #!/bin/bash at the beginning of a script file?
- How to get the url of the current svn repo?
- What does pss mean in /proc/pid/smaps
- apt-get error: Sub-process /usr/bin/dpkg returned an error code (1)
- How do I find all files containing specific text on Linux?
- How to unmount a busy device
- Please run `npm cache clean`
- How to unmount a busy device
- What is the difference between npm install and npm run build?
- error: ‘Can’t connect to local MySQL server through socket ‘/var/run/mysqld/mysqld.sock’ (2)’ — Missing /var/run/mysqld/mysqld.sock
- performing HTTP requests with cURL (using PROXY)
- npm ERR cb() never called
- Where can I find php.ini?
- gzip: stdin: not in gzip format tar: Child returned status 1 tar: Error is not recoverable: exiting now
- NPM clean modules
- ‘node’ is not recognized as an internal or an external command, operable program or batch file while using phonegap/cordova
- error: ‘Can’t connect to local MySQL server through socket ‘/var/run/mysqld/mysqld.sock’ (2)’ — Missing /var/run/mysqld/mysqld.sock
- No space left on device
- How do I grep recursively?
- How can I recursively find all files in current and subfolders based on wildcard matching?
- How to perform grep operation on all files in a directory?
- “E: Unable to locate package python-pip” on Ubuntu 18.04 [duplicate]
- Amazon Linux: apt-get: command not found
- NPM Start not starting local server
- How to install grub after installing Windows 10
- Linux: ‘Username’ is not in the sudoers file. This incident will be reported
- how to find libstdc++.so.6: that contain GLIBCXX_3.4.19 for RHEL 6?
- How to extract C source code from .so file?
- Pass a password to ssh in pure bash
- subprocess.Popen(): OSError: [Errno 8] Exec format error in python?
- “E: Unable to locate package python-pip” on Ubuntu 18.04 [duplicate]
- How to substitute shell variables in complex text files
- NPM ELIFECYCLE error – using node server.js command
- -bash: syntax error near unexpected token `newline’ for display command
- How can I recursively find all files in current and subfolders based on wildcard matching?
- How do I use grep to search the current directory for all files having the a string “hello” yet display only .h and .cc files?
- What is the –save option for npm install?
- SSH using python script
- Curl command for https ( SSL )
- Node.js – SyntaxError: Unexpected token import
- Node Version Manager install – nvm command not found
- How can I exclude directories from grep -R?
- How to exclude a directory in find . command
- nodemon not working: -bash: nodemon: command not found
- “sed” command in bash
- How can I exclude directories from grep -R?
- Changing the resolution of a VNC session in linux
- After $npm install, Getting Error: Cannot find module ‘../lib/utils/unsupported.js’
- npm install not working in windows
- nodemon not found in npm
- gcc: error: unrecognized command line option
- Node.js – SyntaxError: Unexpected token import
- How to exclude a directory in find . command
- nodemon not found in npm
- How can I find all *.js file in directory recursively in Linux?
- mysql_config not found when installing mysqldb python interface
- Linux error while loading shared libraries: cannot open shared object file: No such file or directory
- How to set proxy for wget?
- Shell command to tar directory excluding certain files/folders
- Argument list too long error for rm, cp, mv commands
- QEMU: /bin/sh: can’t access tty; job control turned off
- ExpressJS – throw er Unhandled error event
- How to change permissions for a folder and its subfolders/files in one step
- Difference between using “chmod a+x” and “chmod 755”
- Explaining the ‘find -mtime’ command
- Meaning of exit status 1 returned by linux command
- Building HelloWorld C++ Program in Linux with ncurses
- npm ERR! code UNABLE_TO_GET_ISSUER_CERT_LOCALLY
- How does “cat << EOF" work in bash?
- ssh: Could not resolve hostname [hostname]: nodename nor servname provided, or not known