admin管理员组文章数量:1394735
I'm incredibly new to Node.JS (My background is Unity C# if that helps you with any parisons).
I'm on the chat tutorial for Socket.IO
/
I don't understand what this means
First let’s create a package.json manifest file that describes our project.
I remend you place it in a dedicated empty directory (I’ll call mine
chat-example).
{
"name": "socket-chat-example",
"version": "0.0.1",
"description": "my first socket.io app",
"dependencies": {}
}
Now, in order to easily populate the dependencies with the things we need, we’ll
npm install --save [email protected]
- What is 'Save'?
- Is this meant to be used on a mand prompt on the server with Node.JS installed?
I'm incredibly new to Node.JS (My background is Unity C# if that helps you with any parisons).
I'm on the chat tutorial for Socket.IO
http://socket.io/get-started/chat/
I don't understand what this means
First let’s create a package.json manifest file that describes our project.
I remend you place it in a dedicated empty directory (I’ll call mine
chat-example).
{
"name": "socket-chat-example",
"version": "0.0.1",
"description": "my first socket.io app",
"dependencies": {}
}
Now, in order to easily populate the dependencies with the things we need, we’ll
npm install --save [email protected]
- What is 'Save'?
- Is this meant to be used on a mand prompt on the server with Node.JS installed?
- Possible duplicate of What is the --save option for npm install? – xkcd149 Commented Jan 9, 2017 at 6:46
3 Answers
Reset to default 5- --save means you want the npm mand to write in your package.json file the package(s) he just installed with their corresponding versions. Specifically in the dependencies property. It is important for distributing your code to a hosting service and others.
- When you have installed node.js, you have the possibility of opening a terminal and executing this mand. On some servers, the package.json is executed automatically. That is, the dependencies will be installed, the the scripts will be run.
--save will add the dependency to the package.json file. For example, if you have a package.json that looks like
{
"name": "shared",
"version": "1.0.0",
"description": "Webapp for XYZ",
"author": "Harsha Venkatram",
"license": "ISC"
}
and you do npm install --save express
the package.json would bee
{
"name": "shared",
"version": "1.0.0",
"description": "Webapp for XYZ",
"author": "Harsha Venkatram",
"license": "ISC",
"dependencies": {
"express": "^4.14.0"
}
}
After which you can use the express framework in your node server JS file like so
import express from 'express'
Can we use npm install express
, yes we definitely could and it would still work when you import, the difference being, if you want to host your project on a server, you would have to again do an npm install express
after logging onto your server. However, if you had used the --save
option, just an npm install
would download all the dependencies !
Here is the duplicate question: https://stackoverflow./a/19578808/5410166
Yes, it is run on the terminal of the puter with nodejs and npm installed, a server or your dev puter.
本文标签: javascriptWhat does npm install save express4102 mean and how do I use itStack Overflow
版权声明:本文标题:javascript - What does npm install --save express@4.10.2 mean and how do I use it? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744105468a2591044.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论