logo

该视频仅会员有权观看

立即开通课程「Node.js基础」权限。

¥
199
/ 年

npm:安装包

To install necessary packages in a project, use the command n b m install in the project's directory, which can be accessed from the desktop as x b two note and opened with an editor like code. After opening package.jason in the project, execute n p m install with the package name added, such as express. If a specific version is required, append the version number with the @ symbol; otherwise, n p m will install the latest version, which can be found on p m g s.com. The installation command can include options like safe, which is added by default by n b m to record the package in package.jason. Once the command is executed, n b m will download the package and its dependencies into the node_modules directory. The package.jason file will show the new dependency and its version number.

n p m also creates a package-lock.jason file that details all installed packages, and while the contents of node_modules can be ignored in source code management, package.jason and package-lock.jason should be included. To rebuild the node_modules directory, simply run n b m install without any package names, and n p m will install all dependencies listed in package.jason. The node_modules directory will reappear, and if it's not visible in the editor, it can be refreshed through the command panel by searching "reloads".