Q. Node.js 全域變數
Variables Description
__dirname 目前所在工作路徑
Q.How to install a module?

安裝全域(global)套件

npm install <module name> -g

移除全域套件

npm uninstall <module name> -g

列出全域套件

npm ls -g

列出專案裡的套件

npm ls

更新全域套件

npm update -g

安裝套件並加入package.json的dependencies section 中

npm install--save<module-name>

npm 完整介紹

Q. How to start a node package ?

Ans.

npm start [-- <args>]

Description

This runs an arbitrary command specified in the package's"start"property of its"scripts"object. If no"start"property is specified on the"scripts"object, it will runnode server.js.

ex:

Edit package.json and input follwing

"scripts": {

"start": "node your-script.js"

}

results matching ""

    No results matching ""