Claim your Biolink Click Here
0 like 0 dislike
587 views
in Education & Reference by (830 points) | 587 views

1 Answer

0 like 0 dislike

Make a directory somewhere in your drive
AND
Open the Windows POWER-SHELL and

PS C:> cd D:\
PS D:>
PS D:>
PS D:>
PS D:> cd .\sunnyNode
PS D:\sunnyNode> ls
PS D:\sunnyNode>
PS D:\sunnyNode>
PS D:\sunnyNode> npm init
This utility will walk you through creating a package.json file.
It only covers the most common items, and tries to guess sensible defaults.

See npm help init for definitive documentation on these fields
and exactly what they do.

Use npm install <pkg> afterwards to install a package and
save it as a dependency in the package.json file.

Press ^C at any time to quit.
package name: (sunnynode)
version: (1.0.0)
description: test
entry point: (index.js)
test command:
git repository:
keywords:
author:
license: (ISC)
About to write to D:\sunnyNode\package.json:

{
"name": "sunnynode",
"version": "1.0.0",
"description": "test",
"main": "index.js",
"scripts": {

"test": "echo \"Error: no test specified\" && exit 1"

},
"author": "",
"license": "ISC"
}

Is this OK? (yes) yes
PS D:\sunnyNode>
PS D:\sunnyNode>
PS D:\sunnyNode> npm install
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN sunnynode@1.0.0 No repository field.

up to date in 0.82s
found 0 vulnerabilities

PS D:\sunnyNode>
PS D:\sunnyNode> npm install -g pkg
C:\Users\dvt3\AppData\Roaming\npm\pkg -> C:\Users\dvt3\AppData\Roaming\npm\node_modules\pkg\lib-es5\bin.js
+ pkg@5.3.3
added 154 packages from 145 contributors in 23.031s

Make a file app.js and write consile.log('hello');
to test type the below command

PS D:\sunnyNode> node app.js
hello
PS D:\sunnyNode>
PS D:\sunnyNode>
PS D:\sunnyNode> pkg app.js
pkg : File C:\Users\dvt3\AppData\Roaming\npm\pkg.ps1 cannot be loaded because running scripts is disabled on this
system. For more information, see about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170.
At line:1 char:1
+ pkg app.js
+ ~~~

+ CategoryInfo          : SecurityError: (:) [], PSSecurityException
+ FullyQualifiedErrorId : UnauthorizedAccess

PS D:\sunnyNode>
PS D:\sunnyNode>
PS D:\sunnyNode>
PS D:\sunnyNode>
PS D:\sunnyNode>
PS D:\sunnyNode> Set-ExecutionPolicy RemoteSigned -Scope CurrentUser

Execution Policy Change
The execution policy helps protect you from scripts that you do not trust. Changing the execution policy might expose
you to the security risks described in the about_Execution_Policies help topic at
https:/go.microsoft.com/fwlink/?LinkID=135170. Do you want to change the execution policy?
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "N"): Y
PS D:\sunnyNode>
PS D:\sunnyNode>
PS D:\sunnyNode> pkg app.js
> pkg@5.3.3
> Targets not specified. Assuming:
node14-linux-x64, node14-macos-x64, node14-win-x64
> Fetching base Node.js binaries to PKG_CACHE_PATH
fetched-v14.17.6-linux-x64 [====================] 100%

fetched-v14.17.6-win-x64 [====================] 100%

fetched-v14.17.6-macos-x64 [====================] 100%

PS D:\sunnyNode>
PS D:\sunnyNode> npm install -g express-generator
npm WARN deprecated mkdirp@0.5.1: Legacy versions of mkdirp are no longer supported. Please update to mkdirp 1.x. (Note that the API surface has changed to use Promises in 1.x.)
C:\Users\dvt3\AppData\Roaming\npm\express -> C:\Users\dvt3\AppData\Roaming\npm\node_modules\express-generator\bin\express-cli.js
+ express-generator@4.16.1
added 10 packages from 13 contributors in 2.995s
PS D:\sunnyNode>
PS D:\sunnyNode>
PS D:\sunnyNode>
PS D:\sunnyNode>
PS D:\sunnyNode>
PS D:\sunnyNode> cd ..
PS D:>
PS D:>
PS D:>
PS D:>
PS D:> ll
ll : The term 'll' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the
spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ ll
+ ~~

+ CategoryInfo          : ObjectNotFound: (ll:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException

PS D:>
PS D:>
PS D:> express --view=ejs sunnyNode
destination is not empty, continue? [y/N] y

create : sunnyNode\
create : sunnyNode\public\
create : sunnyNode\public\javascripts\
create : sunnyNode\public\images\
create : sunnyNode\public\stylesheets\
create : sunnyNode\public\stylesheets\style.css
create : sunnyNode\routes\
create : sunnyNode\routes\index.js
create : sunnyNode\routes\users.js
create : sunnyNode\views\
create : sunnyNode\views\error.ejs
create : sunnyNode\views\index.ejs
create : sunnyNode\app.js
create : sunnyNode\package.json
create : sunnyNode\bin\
create : sunnyNode\bin\www

change directory:

 > cd sunnyNode

install dependencies:

 > npm install

run the app:

 > SET DEBUG=sunnynode:* & npm start

PS D:> cd sunnyNode
PS D:\sunnyNode> npm install
added 54 packages from 38 contributors and audited 55 packages in 6.783s
found 0 vulnerabilities

PS D:\sunnyNode>
PS D:\sunnyNode>
PS D:\sunnyNode>
PS D:\sunnyNode>
PS D:\sunnyNode> node .\bin\www
GET / 200 24.268 ms - 207
GET /stylesheets/style.css 200 5.858 ms - 111
GET /favicon.ico 404 3.706 ms - 823

//TO COMPILE

PS D:\sunnyNode> pkg .
> pkg@5.3.3

TO TEST--OPEN THE BROWSER
http://localhost:3000/

If everything works

Express
Welcome to Express

{
"name": "sunnynode",
"version": "0.0.0",
"private": true,
"main": "./bin/www",
"bin": "./bin/www",
"scripts": {

"start": "node ./bin/www"

},

"dependencies": {

"cookie-parser": "~1.4.4",
"debug": "~2.6.9",
"ejs": "~2.6.1",
"express": "~4.16.1",
"http-errors": "~1.6.3",
"morgan": "~1.9.1"

},
"pkg": {

"assets": ["views/**/*", "public/**/*", "routes/**/*"],
"targets": [ "node14-win-x64" ]

}
}

by (4.7k points)
0 0

Related questions

2 like 0 dislike
1 answer
0 like 0 dislike
2 answers
0 like 0 dislike
0 answers
asked Sep 18, 2013 in Computers & Internet by anonymous | 598 views
1 like 0 dislike
1 answer
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
asked Jul 7, 2014 in Education & Reference by Bhoomika (-30 points) | 27.4k views

Where your donation goes
Technology: We will utilize your donation for development, server maintenance and bandwidth management, etc for our site.

Employee and Projects: We have only 15 employees. They are involved in a wide sort of project works. Your valuable donation will definitely boost their work efficiency.

How can I earn points?
Awarded a Best Answer 10 points
Answer questions 10 points
Asking Question -20 points

1,312 questions
1,473 answers
569 comments
4,809 users