Angular-Install

Thanaroj chareonphuthiwat
2 min readJun 22, 2019

--

  1. Install Node js

This package has installed:

  • Node.js v10.16.0 to /usr/local/bin/node
  • npm v6.9.0 to /usr/local/bin/npm

Make sure that /usr/local/bin is in your $PATH.

2.check

npm -v

node -v

docker run --name nodejs -it -d -p 8300:80 -v /Users/thinktho1/www/angular/:/opt/data/ node:12.4 bash

npm -v

cd /opt/data

npm install -g @angular/cli

//ดู Version Angular

ng --version

//Change port

ng serve --port 4100

2.Install VSCode

copy project ที่มี angular อยู่

npm install

sudo npm audit fix

##ขั้นตอนถ้าเราได้ Theme Angular มาให้ทำตามดังนี้

sudo npm install

ng serve --port 4400 -o

--port คือ กำหนด Port

  • o คือ เปิด Browser ให้อัตโนมัติ

##สร้าง Componate

ng g c views/pages/my-page

##ลง Node ใหม่กรณีที่ program มีปัญหา

1.Delete node_modules

2.Uninstall/reinstall node

3. Cache Clean

npm cache clean --force
npm install -g @angular/cli

4.npm install node-sass@4.12.0

5.sudo npm install

6.ng serve — port 4400 -o

— — — — — — — — — — — — — — — — — — — — — — — — — — — — —

ปัญหาที่เจอ
เมื่อ run . npm install ใน project ที่กำลังพัฒนา
แล้วเจอปัญหาแบบนี้ Unexpected end of JSON input while parsing near

การแก้ไขนั้นมีเพียบเลยจึงสรุปไว้หน่อย
ซึ่งเป็นปัยหามาจาก cached ของ npm เอง

  1. ลบไฟล์ package-lock.json และ run npm cache clear –force
  2. ทำการลบ npm cached ตรง ๆ ที่ ~/.npm บน Linux/Mac หรือ %AppData%/npm-cache บน Windows

--

--

No responses yet