当前位置:网站首页>package. json
package. json
2022-04-21 10:59:00 【Qwe7】
6、package.json
(1)node_modules Folder problems
Too many folders and files are broken , When we copy the whole project to others ,, The transmission speed will be very slow .
Complex module dependencies need to be documented , Make sure that the version of the module is consistent with the current version , Otherwise, the current project operation will report an error
(2)package.json Role of documents
Project description file , Record the current project information , For example, project name 、 edition 、 author 、github Address 、 What third-party modules the current project depends on .
Use npm init -y Command to generate .
(3) Project dependence
In the development stage and online operation stage of the project , All need to rely on third-party packages , It's called project dependency
Use npm install The files downloaded by the package name command will be added to by default package.json Of documents dependencies Field
{
"dependencies": {
"jquery": "^3.3.1“
}
}
(4) Development depends on
In the development phase of the project, we need to rely on , Third party package that does not need to be relied on in the online operation stage , It's called development dependency
Use npm install Package name --save-dev Command add package to package.json Of documents devDependencies Field
{
"devDependencies": {
"gulp": "^3.9.1“
}
}
(5)package-lock.json Role of documents
Lock the version of the package , Make sure you don't have problems with the different versions of the package when you download it again
Faster downloads , Because the tree structure of the third-party package that the project depends on and the download address of the package have been recorded in this file , When reinstalling, just download it , There's no need to do extra work
7、Node.js Module loading mechanism in
(1) Module search rules - When a module has a path but no suffix
require Methods search the module according to the module path , If it's a full path , Directly introduce modules .
If the module suffix is omitted , Find the same name first JS Find the same name for the document JS Folder
If you find a folder with the same name , Look for... In the folder index.js
If there is no index.js I'll go to... In the current folder package.json Find in the file main Entry file in options
If the specified entry file does not exist or does not exist, an error will be reported , Module not found
(2) Module search rules - When the module has no path and no suffix
Node.js Assume it's a system module
Node.js Will go to node_modules In the folder
First of all, see if there is a JS file
See if there is a folder with that name
If it's a folder, see if there is index.js
without index.js See... In this folder package.json Medium main Option to determine the module entry file
Otherwise, we can't find the wrong report
版权声明
本文为[Qwe7]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204211054580996.html
边栏推荐
- O2OA二次开发-使用开源平台搭建完整OA(3)-开发企业报销审批
- Special training of AC automata
- Applet lifecycle
- MATLAB---坐标轴多图片显示
- Use of go function
- Activity registration | how to quickly complete the development of data sources and targets based on the open source project tapdata PDK?
- make the inifile support unicode in delphi
- Go uses channel for synchronization (channel 1)
- Enter the welcome interface when idea and pycharm are started
- AC automata
猜你喜欢

万元礼品奖池 玩转「Lighthouse」有奖征文来袭

pgpool-II 4.3 中文手册 - 入门教程

Openshift 4 - improve client access API server security

O2oa secondary development - use the open source platform to build a complete OA (3) - development enterprise reimbursement approval

AcWing 1761. Block billboard (computational geometry, intersection of two rectangles)

从思维转变看数字化转型 IT 经营

P4 Tutorials---- source routing

桶排序 ← C语言实现

Showcase时手机不够怎么办? 云真机平台atxserver2

Bucket sorting ← C language implementation
随机推荐
AC自动机&后缀数组复习
MATLAB---坐标轴多图片显示
There was a problem during PIP install, unable to connect (PIP configure mirror source)
MATLAB---选择省份城市应用
Suffix array special training
Browser plug-in (BD new tab) wallpaper appreciation
Use of laravel redis
MATLAB GUI--ScrollBar(动画演示)
Map与JsonObject区别
現代精算風險理論07:風險度量
Théorie moderne du risque actuariel 07: mesure du risque
MATLAB GUI应用---摇奖(动画演示)
MySQL in-depth study (30): database design specification
MATLAB---采用坐标轴及其子对象制作模拟时钟(动画演示)
js---call,apply,bind
How to write product requirements document (PRD) with the idea of five elements of user experience
Applet lifecycle
[wcn685x] how to determine which bdwlan file is called by WiFi driver?
An error occurred while processing your request...enable the Development environment by setting ...
你的思维会改变你的行为,你的行为会改变你的境遇