Question:
How to set up npm package.json correctly? Did I do it correctly, and what is the function of the following "main": "index.js"
sections "main": "index.js"
, "devDependencies"
and "scripts"
?
{
"name": "progectapi2", //Имя проекта
"version": "1.0.0", //Версия вашего проекта
"description": "test", //Описание проекта
"main": "index.js", //Исходный файл npm, или чего именно?
"dependencies": { //Зависимости для загрузки пакетов
"sass": "^0.5.0"
},
"devDependencies": {}, // Точно не известно, вроде бы для публикации
"scripts": { // Какой то тест скриптов
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "My_Name", //Имя автора
"license": "UNLICENSED"//Лицензия
}
Answer:
Basic configuration can be done simply by running npm init
at the root of the project. And devDependencies
is the project's dev dependencies. When installing something via npm, you can use the --save-dev
flag and this package will be written to devDependencies
, this is useful so that another person deploying a project can use the npm install
command to npm install
all the necessary devDependencies
. main
used to be able to load your package as require("mainpackname")
In scripts
you can write commands that can be run by npm your command. Example "start": "node app.js"
will make the npm start
command available to you. But it is better, at least once, to carefully read the documentation.