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.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744105469a4558705.html
评论列表(0条)