Thursday 31 December 2020

Basics of Node.js and NPM

Check node.js version->     node -v

Check npm version->         npm -v


Initializing package.json

At the command prompt in your git-test folder, type

npm init

Follow along the prompts and answer the questions as follows: accept the default values for most of the entries, except set the entry point to index.html. This should create a package.json file in your project folder.


Install an NPM module, lite-server, that allows you to run a Node.js based development web server and serve up your project files. To do this, type the following at the prompt:

npm install lite-server --save-dev

[save-dev -> this option specifies lite server is used for development dependency for project] 


Update package.json, to run lite server

"scripts": {

    "start":"npm run lite",

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

    "lite":"lite-server"

  },

  

 Now to start the server type command ->  npm start 

 Create .gitignore file and add entry of node_module [folder], so that its skipped during commit


.......................

also, do you think if they can use core components for any or their custom components?

Go live recommendations



        

Install modules for automation

[change in file should recompile automatically by watch/onChnage module]


npm install --save-dev onchange@3.3.0 parallelshell@3.0.2


add script in package.json 

"watch:scss": "onchange \"css/*.scss\" -- npm run scss",

    "watch:all": "parallelshell \"npm run watch:scss\" \"npm run lite\""

update script to

"start": "npm run watch:all",

 

Run:

npm start

*if getting any error update below file from node_module

https://raw.githubusercontent.com/darkguy2008/parallelshell/master/index.js


...........................

helps clean out all files->

npm install --save-dev rimraf@3.0.2


script ->

"clean": "rimraf dist",


npm -g install copyfiles@2.4.1


script->

"copyfonts": "copyfiles -f node_modules/font-awesome/fonts/* dist/fonts",


compress image

npm -g install imagemin-cli@3.0.0

No comments:

Post a Comment