Linux下高效使用 JS 的开发实践
一 环境搭建与版本管理
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
source ~/.bashrc
nvm install --lts
nvm use --lts
node -v && npm -v
curl -o- -L https://yarnpkg.com/install.sh | bash
source ~/.bashrc
yarn -v
二 编辑器与调试工作流
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"program": "${workspaceFolder}/index.js"
}
]
}
三 运行与构建前端项目
mkdir my-app && cd my-app
npm init -y
npm install webpack webpack-cli --save-dev
npm install babel-loader @babel/core @babel/preset-env --save-dev
# 或
yarn add webpack webpack-cli -D
yarn add babel-loader @babel/core @babel/preset-env -D
{
"scripts": { "start": "webpack serve --open" }
}
四 高效调试与性能优化
五 日常效率与排错命令清单