前端时间拿到一份比较旧的项目代码,奈何领导想看,所以用了新的node16来跑,最后适配好后webpack构建的代码语法错误,所以还是用回旧版的环境,但是又不想装两个node,所以自己研究了套方案来整
编写脚本
配合 vscode 的运行脚本,最后实现如下
.vscode
├─ node14
│ ├─ docker-compose.yml
│ └─ Dockerfile
└─ launch.json
编写 Dockerfile
FROM node:14.19.1
WORKDIR /home
编写 docker-compose.yml
version: '3'
services:
node14:
build: ./
image: node14:latest
container_name: node14
tty: true
volumes:
- ../../:/home
restart: always
command: /bin/bash
编写运行脚本
{
"version": "0.2.0",
"configurations": [
{
"command": "docker exec -it node14 /bin/bash -c 'npm install'",
"name": "docker npm install",
"request": "launch",
"type": "node-terminal"
},
{
"command": "docker exec -it node14 /bin/bash -c 'npm run dev'",
"name": "docker dev",
"request": "launch",
"type": "node-terminal"
},
{
"command": "docker exec -it node14 /bin/bash -c 'npm run build'",
"name": "docker build",
"request": "launch",
"type": "node-terminal"
}
]
}
最后,愉快的开发
© 版权声明
THE END
暂无评论内容