Resolving Node Multiple Version Issues in Daily Development
react
Scripts and configuration files related to the React projectvue
Scripts and configuration files related to the Vue projectDockerfile
Node Docker Build FileMakefile
-
parameters
NODE_VERSION
node version- see https://hub.docker.com/_/node/tags?page=1&name=alpine NODE_VERSION?=20.6.0-alpine3.18
IMAGE_NAME
image name- eg
NODE_VERSION=20.6.0-alpine3.18
So, let's name the image jenson/node-20.6.`
- eg
-
command
make add
// Create a default version imagemake add NODE_VERSION=20.6.0-alpine3.18 IMAGE_NAME=jenson/node-20.6
The Dockerfile checks the version and automatically selects the appropriate Python version to create. Preferably, choose version 3.15 for building. If you opt for an Alpine version above 3.15, Python will be Python 3. This is mainly to address compatibility issues with previous Node-sass compilation.
-
Remember the name of the built image, for example: jenson/node-17.5. You will need to use IMAGE_NAME below.
- Choose the appropriate configuration directory based on your project framework, either vue or react.
- If the target project already has this file, please add it manually. Otherwise, simply copy it.
- According to the comments in env.development.example, configure it into .env.development.
make help
show help
-
make add NODE_VERSION=14-alpine3.17 IMAGE_NAME=jenson/node-14
-
git clone test project
git clone https://github.com/hsl947/react-antd-multi-tabs-admin.git
-
copy ./react config file
Please pay attention to .env.development.
-
set .env.development
# must # IMAGE_NAME="{your generate node}" # eg: IMAGE_NAME="jenson/node-20.6" IMAGE_NAME="jenson/node-14.21.3" # must # backend api domain # like setupProxy.js proxy REACT_APP_HOST_DOMAIN="" # must # Backend api ip, If the domain name used does not resolve # Used in dnode.sh to set host REACT_APP_HOST_IP="" # your dev port PORT=3000
-
install node_module
make install
-
start
make start