打字稿更改后 nodemon 未重新启动
nodemon not restarting after typescript change
我的 nodemon 在 typescript 文件更改后没有重新启动。
目前我正在使用以下内容 运行 并编译我的更改:
"dev": "nodemon -e ts,json --exec \"npm run compile\"",
"compile": "tsc && node src/index.js"
它应该检测到 ts 更改并重新编译,但它没有。
它是运行通过一个docker容器链接到一个volume,volume中的代码要注意。
docker-撰写
version: '2'
services:
api:
build:
context: ./api
ports: ["5000:5000"]
environment:
- NODE_ENV=production
覆盖:
version: '2'
services:
api:
command: yarn run dev
volumes:
- ./api/src:/usr/workspace/api/src
environment:
- NODE_ENV=dev
api有以下docker文件
FROM node:latest
# Install yarn
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - \
&& echo "deb http://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list && apt-get update && apt-get clean
# Set working dir and copy contents of our images to that dir
RUN mkdir -p /usr/workspace/api && cd /usr/workspace/api
# install dependencies
COPY *.json /usr/workspace/api/
WORKDIR /usr/workspace/api
# npm install will check NODE_ENV if its production if will not install dev dependencies
RUN npm install --silent && npm install -g nodemon pm2 typescript --silent
# copy sources
COPY ./src ./src
# create env file with the port
ENV PORT 8100
EXPOSE $PORT
CMD ["pm2-docker", "src/process.json"]
如您所见,使用覆盖 i 运行 开发环境而不是暂存 [=14=]
我已经尝试在我的 tsconfig 中将 watch 选项设置为 true,但是代码不会重新 运行。当我更改 nodemon 选项以监视 js 文件时,它也能正常工作,但是它会不断重建,因为它在编译时检测到 js 文件更改。
有什么意见吗?
我通过向 nodemon 添加 -L
开关解决了这个问题。这显然使用了在 docker 容器
上工作的遗留手表
"dev": "nodemon -L -e ts,json --exec \"npm run compile\"",
我的 nodemon 在 typescript 文件更改后没有重新启动。
目前我正在使用以下内容 运行 并编译我的更改:
"dev": "nodemon -e ts,json --exec \"npm run compile\"",
"compile": "tsc && node src/index.js"
它应该检测到 ts 更改并重新编译,但它没有。
它是运行通过一个docker容器链接到一个volume,volume中的代码要注意。
docker-撰写
version: '2'
services:
api:
build:
context: ./api
ports: ["5000:5000"]
environment:
- NODE_ENV=production
覆盖:
version: '2'
services:
api:
command: yarn run dev
volumes:
- ./api/src:/usr/workspace/api/src
environment:
- NODE_ENV=dev
api有以下docker文件
FROM node:latest
# Install yarn
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - \
&& echo "deb http://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list && apt-get update && apt-get clean
# Set working dir and copy contents of our images to that dir
RUN mkdir -p /usr/workspace/api && cd /usr/workspace/api
# install dependencies
COPY *.json /usr/workspace/api/
WORKDIR /usr/workspace/api
# npm install will check NODE_ENV if its production if will not install dev dependencies
RUN npm install --silent && npm install -g nodemon pm2 typescript --silent
# copy sources
COPY ./src ./src
# create env file with the port
ENV PORT 8100
EXPOSE $PORT
CMD ["pm2-docker", "src/process.json"]
如您所见,使用覆盖 i 运行 开发环境而不是暂存 [=14=]
我已经尝试在我的 tsconfig 中将 watch 选项设置为 true,但是代码不会重新 运行。当我更改 nodemon 选项以监视 js 文件时,它也能正常工作,但是它会不断重建,因为它在编译时检测到 js 文件更改。
有什么意见吗?
我通过向 nodemon 添加 -L
开关解决了这个问题。这显然使用了在 docker 容器
"dev": "nodemon -L -e ts,json --exec \"npm run compile\"",