Node(2),前端h5开发

37 阅读5分钟

最后

正值招聘旺季,很多小伙伴都询问我有没有前端方面的面试题!

前端资料图.PNG 开源分享:docs.qq.com/doc/DSmRnRG…

  1. 将安装包放在 ./node_modules 下(运行 npm 命令时所在的目录),如果没有 node_modules 目录,会在当前执行 npm 命令的目录下生成 node_modules 目录。

  2. 可以通过 require() 来引入本地安装的包。

  • 全局安装
  1. 将安装包放在 /usr/local 下或者node 的安装目录。

  2. 可以直接在命令行里使用。

例如: npm 命令本地安装常用的 Node.js web框架模块 express。

npm install express

在这里插入图片描述

当前路径下生成了一个目录node_modules和一个文件package-lock.json。

node_modules目录:

在这里插入图片描述

express目录:

在这里插入图片描述

package.json文件:

在这里插入图片描述

Package.json 属性说明:

  • .name - 包名。

  • .version - 包的版本号。

  • .description - 包的描述。

  • .homepage - 包的官网 url 。

  • .author - 包的作者姓名。

  • .contributors - 包的其他贡献者姓名。

  • .dependencies - 依赖包列表。如果依赖包没有安装,npm 会自动将依赖包安装在 node_module 目录下。

  • .repository - 包代码存放的地方的类型,可以是 git 或 svn,git 可在 Github 上。

  • .main - main 字段指定了程序的主入口文件,require(‘moduleName’) 就会加载这个文件。这个字段的默认值是模块根目录下面的 index.js。

  • .keywords - 关键字

卸载模块

===============================================================

卸载模块命令:

$ npm uninstall express

在这里插入图片描述

卸载后,到 /node_modules/ 目录下查看,express包没有了,或者使用以下命令查看:

$ npm ls

更新模块

===============================================================

命令:

$ npm update express

搜索模块

===============================================================

命令:

$ npm search express

创建模块

===============================================================

  • 新建项目目录:

E:\project\hookhook

  • 在目录里写个js文件thress.js。

function hello(){

console.log("Give you a hook");

}

exports.hello=hello;

  • package.json

用 npm 命令来创建package.json 文件,

npm init

如果是要发布模块的话,keywords填npmjs.com上的密码,author填npmjs.com的名字。也可以随便填,要发布的时候再改package.json也是可行的。

在这里插入图片描述

详解:

$ npm init

This utility will walk you through creating a package.json file.

It only covers the most common items, and tries to guess sensible defaults.

See npm help json for definitive documentation on these fields

and exactly what they do.

Use npm install <pkg> --save afterwards to install a package and

save it as a dependency in the package.json file.

Press ^C at any time to quit.

name: (node_modules) runoob # 模块名

version: (1.0.0)

description: Node.js 测试模块(www.runoob.com) # 描述

entry point: (index.js)

test command: make test

git repository: github.com/runoob/runo… # Github 地址

keywords: #密码

author: #名字

license: (ISC)

About to write to ……/node_modules/package.json: # 生成地址

{

"name": "runoob",

"version": "1.0.0",

"description": "Node.js 测试模块(www.runoob.com)",

……

}

Is this ok? (yes) yes

{

"name": "hookhook",

"version": "1.0.0",

"description": "heyhook",

"main": "three.js",

"scripts": {

"test": "make test"

},

"keywords": [

"laughter8888"

],

"author": "laughter",

"license": "ISC"

}

发布模块

===============================================================

加载的模块从哪来的呢——也是别人发布的,所以同样可以通过npm工具发布模块。

  • 注册

所有npm都是发布在 www.npmjs.com/ 上面的,所以在发布之前,需要到 npmjs 上去注册一个账号,才有权限发布自己定义模块。

在这里插入图片描述

  • 激活账号

注册之后,会发个邮件到邮箱,要激活一下,不然无法发布。

在这里插入图片描述

  • 登录

npm adduser

在这里插入图片描述

登录成功!

  • 发布

登录成功之后就可以发布了。

npm publish

在这里插入图片描述

发布成功。

TCP协议

  • TCP 和 UDP 的区别?
  • TCP 三次握手的过程?
  • 为什么是三次而不是两次、四次?
  • 三次握手过程中可以携带数据么?
  • 说说 TCP 四次挥手的过程
  • 为什么是四次挥手而不是三次?
  • 半连接队列和 SYN Flood 攻击的关系
  • 如何应对 SYN Flood 攻击?
  • 介绍一下 TCP 报文头部的字段
  • TCP 快速打开的原理(TFO)
  • 说说TCP报文中时间戳的作用?
  • TCP 的超时重传时间是如何计算的?
  • TCP 的流量控制
  • TCP 的拥塞控制
  • 说说 Nagle 算法和延迟确认?
  • 如何理解 TCP 的 keep-alive?

开源分享:【大厂前端面试题解析+核心总结学习笔记+真实项目实战+最新讲解视频】

浏览器篇

  • 浏览器缓存?
  • 说一说浏览器的本地存储?各自优劣如何?
  • 说一说从输入URL到页面呈现发生了什么?
  • 谈谈你对重绘和回流的理解
  • XSS攻击
  • CSRF攻击
  • HTTPS为什么让数据传输更安全?
  • 实现事件的防抖和节流?
  • 实现图片懒加载?