![](/img/trans.png)
[英]What does Unexpected token, expected ; mean in ReactJS?
[英]What does "install\r" error mean in Reactjs with Docker using yarn?
我使用 Docker 設置創建了一個 Reactjs 應用程序。 我使用的是 Windows 10。構建后,容器只是不斷重新啟動,在日志上產生錯誤:
yarn run v1.22.5
error Command "install\r" not found.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
: not foundotup.sh: line 3:
/var/www/bootup.sh: line 11: syntax error: unexpected end of file (expecting "then")
文件
# pull official base image
FROM node:12.20.0-alpine3.10
WORKDIR /var/www
COPY package.json /var/www/
RUN yarn install
COPY . /var/www/
# Install create-react-app package
RUN yarn global add react-scripts
EXPOSE 3000
ADD ./bootup.sh /var/www
RUN cd /var/www
RUN chmod +x /var/www/bootup.sh
docker-compose.yml
version: '3.7'
services:
frontend:
build: .
restart: unless-stopped
tty: true
working_dir: /var/www/
ports:
- '3002:3000'
volumes:
- '.:/var/www'
- /var/www/node_modules
environment:
- CHOKIDAR_USEPOLLING=true yarn start
command: /var/www/bootup.sh ${SSL_ON}
啟動文件
# Install Dependencies
yarn install
# Start the react app
if [ "$1" == "true" ]
then
yarn start-https
else
yarn start
fi
我嘗試重新啟動它,殺死容器,再次克隆存儲庫,但問題仍然存在。
我使用另一台筆記本電腦在 Ubuntu 中克隆了 repo,這些錯誤都沒有發生,僅在 Windows 上發生。 如果有人知道這意味着什么,那將是一個很大的幫助。
我根據@HansKilian 關於行尾的評論解決了這個問題。 我遵循了有關如何使用正確的 UNIX 樣式行結尾轉換bootup.sh
文件的鏈接: https : //support.nesi.org.nz/hc/en-gb/articles/218032857-Converting-from-Windows-style -to-UNIX-style-line-endings
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.