npm学习笔记

What is npm?
  1. Packages are structured to enable you to keep track of dependencies and versions.
  2. npm consists of three distinct components:

    • the website

      The website is the primary way developers discover packages, set up profiles, and manage other aspects of their npm experience.

    • the registry

      The registry is a large database of information about packages.

    • the Command Line Interface (CLI)

      The CLI runs from a terminal. This is how most developers interact with npm.

How to Install npm & Manage npm Versions
  1. Installing npm from the Node.js site
    • update npm
      - npm -v
      - npm install npm@latest -g
      - npm install npm@next -g
  2. Using a Version manager to install node.js and npm
    • Since npm and node.js products are managed by different entities, updates and maintenance can become complex. Also, the Node.js installation process installs npm in a directory that only has local permissions. This can cause permissions errors when you attempt to run packages globally.
How to Prevent Permissions Errors

If you see an EACCES error when you try to install a package globally, read this chapter. This error can often be avoided if you change the directory where npm is installed. To do this, either:
1. Reinstall npm with a version manager (recommended).
2. Change npm’s default directory manually.

How to install Local Packages
  1. Installing a Package
    • npm install < package_name >
  2. Which Version of the Package is Installed?
    • If there is no package.json file in the local directory, the latest version of the package is installed.
    • If there is a package.json file, npm installs the latest version that satisfies the semver rule declared in package.json.
How to use Semantic Versioning

这里写图片描述

  1. If you were starting with a package 1.0.4, this is how you would specify the ranges:
    • Patch releases: 1.0 or 1.0.x or ~1.0.4
    • Minor releases: 1 or 1.x or ^1.0.4
    • Major releases: * or x
Working with package.json
  1. Requirements
    • Name
      • All lowercase
      • One word,no spaces
      • Dashes and underscores allowed
    • Version
      • In the form of x.x.x
      • Follows semver spec
  2. Createing a package.json
    • Run a CLI questionnaire
    • Create a default package.json
  3. Use Customize the package.json questionnaire
    • Create a custom .npm-init.js in ~/
  4. Specifying Dependencies

    • Dependencies

      These packages are required by your application in production

    • devDependencies

      Theses packages are only needed for development and testing

  5. npm install

    Default add to dependencies

  6. npm install –save

    Reinstall can not cover devDenpendencies

  7. npm install –save-dev

    Reinstall can cover denpendencies

How to Update Local Packages
  1. npm update [-g] [< pkg >]
  2. npm outdated
How to Uninstall Local Packages
  1. npm uninstall < package > [–save][–save-dev]
    It will remove package define in package.json whether it in devDenpendenices Object or not in Denpendenices by use –save or –save-dev
How to Install Global Packages
  1. There are two ways to install npm packages: locally or globally. Choose which kind of installation to use based on how you want to use the package.
    • If you want to use a package as a command line tool, then install it globally. This way, it works no matter which directory is current. This is the choice you would use if you were installing grunt, for example.
    • If you want to depend on the package from your own module, then install it locally. This is the choice you would use if you are using require statements, for example.
  2. npm install -g < package-name >
How to Update Global Packages
  1. npm update -g
  2. npm outdated -g
How to uninstall global packages
  1. npm uninstall -g < package_name >
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
毕业设计,基于SpringBoot+Vue+MySQL开发的影城管理系统,源码+数据库+论文答辩+毕业论文+视频演示 随着现在网络的快速发展,网上管理系统也逐渐快速发展起来,网上管理模式很快融入到了许多生活之中,随之就产生了“小徐影城管理系统”,这样就让小徐影城管理系统更加方便简单。 对于本小徐影城管理系统的设计来说,系统开发主要是采用java语言技术,在整个系统的设计中应用MySQL数据库来完成数据存储,具体根据小徐影城管理系统的现状来进行开发的,具体根据现实的需求来实现小徐影城管理系统网络化的管理,各类信息有序地进行存储,进入小徐影城管理系统页面之后,方可开始操作主控界面,主要功能包括管理员:首页、个人中心、用户管理、电影类型管理、放映厅管理、电影信息管理、购票统计管理、系统管理、订单管理,用户前台;首页、电影信息、电影资讯、个人中心、后台管理、在线客服等功能。 本论文主要讲述了小徐影城管理系统开发背景,该系统它主要是对需求分析和功能需求做了介绍,并且对系统做了详细的测试和总结。具体从业务流程、数据库设计和系统结构等多方面的问题。望能利用先进的计算机技术和网络技术来改变目前的小徐影城管理系统状况,提高管理效率。 关键词:小徐影城管理系统;Spring Boot框架,MySQL数据库
TypeScript 是一种由微软开发并维护的开源编程语言。它是 JavaScript 的扩展,为 JavaScript 提供了静态类型检查、类、接口和命名空间等功能。 以下是 TypeScript 的学习笔记: ## 安装 使用 npm 安装 TypeScript: ``` npm install -g typescript ``` ## 编写 TypeScript 代码 TypeScript 文件的扩展名为 `.ts`。可以使用任何文本编辑器来编写 TypeScript 代码。 以下是一个简单的 TypeScript 代码示例: ```typescript function greeter(name: string) { return "Hello, " + name + "!"; } let user = "John"; console.log(greeter(user)); ``` ## 编译 TypeScript 代码 使用 `tsc` 命令编译 TypeScript 代码。例如,将上面的代码编译为 JavaScript: ``` tsc greeter.ts ``` 这将生成一个名为 `greeter.js` 的 JavaScript 文件。 ## 类型注解 TypeScript 中的类型注解指定了变量、函数参数和函数返回值的类型。例如,以下代码指定了 `name` 参数的类型为 `string`: ```typescript function greeter(name: string) { return "Hello, " + name + "!"; } ``` ## 接口 接口定义了一个对象的属性和方法。例如,以下代码定义了一个 `Person` 接口: ```typescript interface Person { firstName: string; lastName: string; } function greeter(person: Person) { return "Hello, " + person.firstName + " " + person.lastName + "!"; } let user = { firstName: "John", lastName: "Doe" }; console.log(greeter(user)); ``` ## 类 类是面向对象编程的基本构建块。以下是一个简单的类的示例: ```typescript class Greeter { greeting: string; constructor(message: string) { this.greeting = message; } greet() { return "Hello, " + this.greeting + "!"; } } let greeter = new Greeter("world"); console.log(greeter.greet()); ``` ## 泛型 泛型允许在编写代码时指定未知的类型。以下是一个泛型函数的示例: ```typescript function identity<T>(arg: T): T { return arg; } let output = identity<string>("hello"); console.log(output); ``` ## 命名空间 命名空间是用于组织和管理代码的方式。以下是一个简单的命名空间的示例: ```typescript namespace MyNamespace { export function sayHello() { console.log("Hello from MyNamespace!"); } } MyNamespace.sayHello(); ``` ## 模块 模块是将代码分离成可重用的单元的方式。以下是一个简单的模块的示例: ```typescript export interface Person { firstName: string; lastName: string; } export class Greeter { greeting: string; constructor(message: string) { this.greeting = message; } greet() { return "Hello, " + this.greeting + "!"; } } ``` 可以使用 `import` 关键字导入模块中的对象: ```typescript import { Person, Greeter } from "./module"; let user: Person = { firstName: "John", lastName: "Doe" }; let greeter = new Greeter("world"); console.log(greeter.greet()); ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值