NodeJs前端开发笔记

#Node.js 教程

创建 Express node.js app

安装Express Generator
npm install -g express-generator

创建 Express app 安装依赖

cd myExpressApp
npm install

启动Express app npm start

启动后默认访问 http://localhost:3000/ 即可看到运行的app.
Express几种常用的模板引擎:http://expressjs.com/en/guide/using-template-engines.html


React 笔记

安装create-react-app生成器
npm install -g create-react-app

创建 my-react-app
create-react-app my-react-app

启动App

cd my-react-app
npm start

访问:http://localhost:3000

编辑App

cd my-react-app
code .

Angular笔记

安装Angular CLI
npm install -g @angular/cli

创建angular app
ng new my-angular-app

启动angular app

cd my-angular-app/
ng serve

TypeScript笔记

安装Typescript编译器

npm install -g typescript
tsc --version   //查看版本号

添加TypeScript目录

mkdir TypeScriptTest
cd TypeScriptTest
code .

添加文件helloworld.ts,编辑

let message : string = "Hello World";
console.log(message);

编译helloworld.ts
tsc helloworld.ts

使用node执行
node helloworld.js


Vue笔记

创建 Vue app

VS code vue tutorial https://code.visualstudio.com/docs/nodejs/vuejs-tutorial

安装
npm install -g @vue/cli

出现权限问题,执行

sudo chown -R $(whoami) ~/.npm
sudo chown -R $(whoami) /usr/local/lib
sudo chown -R $(whoami) /usr/local/bin

# Then try your command again without sudo. e.g.
npm install -g npm@latest

sudo chown -R $(whoami) /Users/luowei/.npm

创建Vue项目

vue create my-app

启动my-app

cd my-app
npm run serve

用code打开

cd my-app
code .

碰到code: command not found
ls /Applications/Visual\ Studio\ Code.app/Contents/Resources/app/bin/


创建Webpack Vue App

参考:https://github.com/Microsoft/vscode-recipes/tree/master/vuejs-cli

Make sure to have Google Chrome installed in its default location.、 Make sure to the latest version of Debugger for Chrome extension installed in VS Code.

Use NPM to install vue-cli
npm install -g vue-cli

Use Vue CLI to create a new Vue.js app.
vue init webpack vuejs-webpack-project

Change to the newly created application directory and open VS Code.

cd vuejs-webpack-project
code .

启动App
npm start


创建 Ember App

参考:https://guides.emberjs.com/v3.10.0/getting-started/quick-start/
install Ember CLI npm install -g ember-cli

创建ember app
ember new my-emberApp

启动ember app

cd my-emberApp/
ember serve

版权所有,转载请注明出处 luowei.github.io.