Preface The previous article introduced the installation and configuration of nodejs. This article will introduce how to use bable in VScode. 1. Check if npm is already installedEnter npm -v in cmd to get the version number. Now the new version of nodejs has automatically installed npm during installation. Again, it is best to open the terminal as an administrator. 2. Configure bableInstall babel in the terminal, enter npm install –g babel-cli This is to allow VScode to recognize bable. After successful installation, it looks like this: This process is super slow, please be patient. 3. Configure in VScode 1. Use vscode ctrl+j to open vscode's built-in terminal
3. Enter npm init –y in the terminal to initialize the project. The correct result is that a package.json file will appear in the bable folder. 4. Install bable This process is also quite long. Since we have already installed the Taobao mirror, we can also use cnmp because nmp may fail, but we may encounter this situation: I use cnmp -v to query the version number as a demonstration There is an error in executing cnmp in the vscode terminal. At this time, just execute in the terminal: set-ExecutionPolicy RemoteSigned Now you can use cnmp normally. 5. Create a new .babelrc file and configure the configuration file content { // The presets property tells bakel which new syntax features are used in the source code to be converted // Convert js to es2015 "presets":["es2015"], // This property tells bable which plugins to use // These plugins can control how to convert code "plugins": [] } 6. File conversion Create a new js file, enter some content (in es6 format), and then convert it in the terminal After entering the command, a converted demo.js file is automatically generated in the folder, which contains the es6 code in test.js converted to es5 This statement is used to convert a single file. Similarly, there is also a direct conversion of all js files in the entire folder: babel src –d dis //src-source folder dis-converted folder There are also statements that can achieve real-time conversion babel src/index.js –w –o dist/index.js babel src –w –d dist This is the end of this article about using npm to install babel in vscode. For more information about installing babel in vscode, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: MySQL randomly extracts a certain number of records
>>: Detailed graphic explanation of hadoop installation and configuration based on Linux7
When the resolution of the login interface is par...
Table of contents Initialize computed Dependency ...
Table of contents When setting up a MySQL master-...
This article shares the specific code of JavaScri...
1. Data backup 1. Use mysqldump command to back u...
Table of contents How to install and configure To...
Table of contents 1. parse 1.1 Rules for intercep...
<br />In the field of network design, resear...
MySQL itself was developed based on the file syst...
Table of contents What is a mind map? How to draw...
Since 2019, both Android and IOS platforms have s...
Table of contents 1. MySQL Architecture 2. Networ...
Ubuntu16.04 install and uninstall pip Experimenta...
Software version and platform: MySQL-5.7.17-winx6...
1. To build a PPTP VPN, you need to open port 172...