npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

1207-publish

v1.0.0

Published

- nodejs 命令行操作 - koa+mysql - egg+mysql - 综合案例

Downloads

6

Readme

lesson1

学习计划

  • nodejs 命令行操作
  • koa+mysql
  • egg+mysql
  • 综合案例

概念

nodejs是什么?

nodejs是基于chrome vs 引擎的javascript 运行环境(runtime)

nodejs 模块

  • 内置模块 nodejs内置(不需要额外下载包)的api就是内置模块,内置模块又被称为核心模块 eg: path url http fs os cluster process、 child_process
  • 外置模块
    • jquery
    • mockjs
    • axios
    • node-dev
    • supervisor
    • ...

npm

由来

由于我们在使用nodejs做开发需求时,有很多基建或者功能需要我们完成,但是我们的精力是有限的,需要将重心放到我们的业务逻辑开发中去,前人、社区给我们提供了很多强大有用的工具库,我们这个时候就需要用npm去下载使用,提升编码速度提升开发效率。

其他包管理器

  • npx
  • yarn
  • cnpm

概念

npm是nodejs官方提供的包管理工具。

npm & npx 区别

npm 会将目标包下载到本地,下次使用时,无需下载直接使用 npx 每次都会在线获取最新版本的包,缓存到本地,下次使用时没有最新版本,直接使用,有的话,重新下载、缓存最新版本使用。

常识

端是什么?

  • 前端 (客户端 client side)
    • html
    • css
    • js
  • 后端 (服务端 server side)
    • java
    • php
    • asp.net c#
    • ruby
    • python

编程语言

- 高级语言
- 低级语言 (机器语言)

nodejs 常用配置命令

全局包的默认路径

   npm root -g (带node_modules)
   npm root  (当前目录的装包路径,就是当前目录-node_modules)

修改全局包的存放路径

    
    npm config get prefix
    npm config set prefix <dir>

修改全局包的缓存路径

    npm config get cache
    npm config set cache <dir>

修改npm镜像源地址

    npm config get registry
    npm config set registry https://registry.npm.taobao.org

process

process是nodejs的一个全局变量,提供很多非常有用的api

  • version nodejs版本号
  • version nodejs依赖库的版本号
    • node
    • zlib
  • platform 平台类型
  • arch 系统版本 x64(64位操作系统) x86(32位操作系统)
  • cwd()
  • env 环境变量

模块化

  • AMD 依赖前置
  • CMD 依赖就近

moduleB.js

   module.exports = function(){}

   module.exports = {
       fun1:function(){},
       fun2:function(){},
   }
   
   exports.fun1 = function(){}
   exports.fun2 = function(){}

moduleA.js

    const app = require('./moduleB.js')
    app();