1. Install the node.js running environment and install the NPM package management tool (the NPM package management tool will be included when installing the node running environment)
1. Enter ( https://nodejs.org/en/download/ ) to download
LTS6.10.0+ Window 64bit .msi
the file (ps: The current Node version of the company’s development environment is, you can use the Nvm management tool to manage the Node version problem, and you can install multiple Node on the computer. Version)2. Run the downloaded
Window 64bit .msi
installation file (click Next all the way to install by default)3. Check the Node version and Npm version
(1), check the installed Node version:node -v
(2), check the Npm version:npm -v
2. Switch the default source of npm to Taobao image
1. View the current npm source
npm config get registry
, the default ishttps://registry.npmjs.org/
(the sourcenpm install
is the warehouse from which the npm package is pulled by default when executing)2. Modify the npm source (choose one of the following three methods)
(1), through the config command, executewindow+R
the key, enter cmd to open the Dos command box of the Window, enternpm config set registry https://registry.npm.taobao.org
(2), command line specification, executewindow+R
the key, enter cmd to open the Dos of the Window In the command box, enternpm --registry https://registry.npm.taobao.org info underscore
(3), edit~/.npmrc
the file and add the following content, open the file explorer,C:/Users/电脑名
find it under the path~/.npmrc
, open~/.npmrc
Replaceregistry = https://registry.npm.taobao.org
3. Install the angular-cli scaffolding tool
1. Execute
npm install -g @angular/cli
the global installation of the angular-cli scaffolding tool. If young -v
successfully query the version number of the angular-cli scaffolding, the installation is successful. For more ng scaffolding operations, please executeng help
4. Initialize the project using angular-cli scaffolding
1. Enter the folder where the project is to be stored, use to
shift+鼠标右键
pop up the prompt box, select在此处打开命令窗口
(orW键+Enter键
) pop up the Window Dos command box2. Enter in the Dos command box
ng new 项目名称
to download the basic template for using scaffolding development projects3. cd into the downloaded project folder and execute
npm install
to install the dependency packages of the project4. Wait for the project dependency package to be installed and execute
ng serve
to start the project.5. After the project development is completed, you can use
ng build
the package project (the angular4+ version uses –aot compilation by default, and the angular2 version uses itng build --aot --prod
)
5. Install the node-sass package (this step is optional. You must install this npm package when you want to compile sass files locally or use .sass files to write style files in project components)
1. Since directly executing
npm install -g node-sass
the command to install the node-sass package will definitely fail, you have the following solutions:
(1) Download over the wall and make sure your computer network is over the wall.npm install -g node-sass
(2) Use node- sass offline installation package offline installation of node-sass package
6. Installation failures you may encounter and their solutions
1. Node-sass installation failed (node-sass requires a pre-installed c++ environment, node-sass is blocked)
(1) Since the default dependency on node-sass has been canceled in the angular4.0 project dependencies, use thenpm install
installation project dependency No error will be reported when(2) If you need to use .scss files in project components, you need to install the node-sass package
(3) Install the dependent environment of node-sass (mainly the dependent c++ environment) and enter it in the window Dos command box
npm install --global --production windows-build-tools
(4) Download over the wall: After bypassing the network wall, open the Window Dos command box, enter
npm install -g node-sass
, and use node-sass -v to check the version of node-sass, which means the download is successful, otherwise it means failure.(5) If you cannot circumvent the wall, use this method. Download the node-sass offline package (win32-x64-51_binding.node, x64-48 version or above), open the window file explorer, and find the folder
C:/Users /window用户名/AppData/Roaming/npm-cache/node-sass/4.5.3(node-sass版本号)
. Delete the package folder and package.tgz file inside, then put the win32-x64-51_binding.node file, then open the window Dos command box and enter tonpm install -g node-sass
globally install the node-sass package. The projects generated by the scaffolding also need to use thenpm install node-sass
node-installation project. Sass depends on the package. You can use node-sass -v to check the node-sass version, which means the download is successful. Otherwise, it means a failure (ps: explain why global installation and project installation are needed. Global installation is to use the node-sass command to compile static files. The .scss file in the resource is a .css file. The project installation is because you use .scss files in the project components, so you need to install the project's sass compilation environment. This means that when the project is packaged and compiled, it will not actively search for node-sass globally. Package compiled .scss file)