Could you try to reproduce or check my commands?
meteor create --typescript myapp
cd myapp
meteor build --directory .build --architecture=os.linux.x86_64 --server-only --platforms=web.browser
cd .build/bundle
export NODE_ENV=production
(cd programs/server && npm install)
node main.js
Uncaught Error: React is running in production mode, but dead code elimination has not been applied. Read how to correctly configure React for production: https://reactjs.org/link/perf-use-production-build
I’ve also checked that meteor --production
gives the same error message
Hello!
I can’t reproduce what you are seeing… What is the value of NODE_ENV when you are running the meteor build command or the meteor --production?
I’ve tried both, and react is minified correctly, also Meteor.isProduction is correctly set.
Thank you
That’s a nice clue, so I’ve changed my command to
meteor create --typescript myapp
cd myapp
export NODE_ENV=production
meteor build --directory .build --architecture=os.linux.x86_64 --server-only --platforms=web.browser
cd .build/bundle
(cd programs/server && npm install)
node main.js
And I also tried
export NODE_ENV=production
meteor --production
But I still got the same error
Here is a bash script with docker that you can use to reproduce. Just copy and paste on your terminal
dockerfile="FROM ubuntu:20.04
ENV DEBIAN_FRONTEND noninteractive
ENV LANG=\"C.UTF-8\"
ENV TZ=Etc/Universal
RUN ln -snf /usr/share/zoneinfo/\$TZ /etc/localtime && echo \$TZ > /etc/timezone
RUN apt-get update && \
apt-get install -y sudo tzdata
RUN useradd -ms /bin/bash ubuntu && \
usermod -aG sudo ubuntu
RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
USER ubuntu
WORKDIR /home/ubuntu
RUN sudo apt-get install wget curl git -y
RUN sudo mkdir -p /usr/local/n && \
sudo chown -R \$(whoami) /usr/local/n && \
sudo mkdir -p /usr/local/bin /usr/local/lib /usr/local/include /usr/local/share && \
sudo chown -R \$(whoami) /usr/local/bin /usr/local/lib /usr/local/include /usr/local/share
RUN wget -q -O n https://raw.githubusercontent.com/tj/n/master/bin/n && \
bash n install 14.18.1
RUN npm install -g meteor
ENV PATH=\"/home/ubuntu/.meteor:\${PATH}\"
WORKDIR /home/ubuntu
"
echo "$dockerfile" | docker build -t meteor-ubuntu:2.5.1 -
docker run -it \
--rm \
-p 3000:3000 \
--entrypoint /bin/bash \
meteor-ubuntu:2.5.1 -c "meteor --version && \
meteor create --typescript myapp && \
cd myapp && \
NODE_ENV=production meteor --production"
I also found that you need to have React Devtools to get this error
Finally, if you use meteor create --release=2.4 ...
in the script above, you won’t see that error, so it’s probably a bug
I’m going to report to github as well
opened 10:50PM - 19 Nov 21 UTC
closed 05:40PM - 23 Nov 21 UTC
Project:Isobuild:Minifiers
To see this error in the console you must have the React Devtools Extension
htt… ps://chrome.google.com/webstore/detail/react-developer-tools/fmkadmapgofadopljbjfkapdkoienihi?hl=en
Copy and paste this script on your terminal, you also need to have docker installed
```bash
dockerfile="FROM ubuntu:20.04
ENV DEBIAN_FRONTEND noninteractive
ENV LANG=\"C.UTF-8\"
ENV TZ=Etc/Universal
RUN ln -snf /usr/share/zoneinfo/\$TZ /etc/localtime && echo \$TZ > /etc/timezone
RUN apt-get update && \
apt-get install -y sudo tzdata
RUN useradd -ms /bin/bash ubuntu && \
usermod -aG sudo ubuntu
RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
USER ubuntu
WORKDIR /home/ubuntu
RUN sudo apt-get install wget curl git -y
RUN sudo mkdir -p /usr/local/n && \
sudo chown -R \$(whoami) /usr/local/n && \
sudo mkdir -p /usr/local/bin /usr/local/lib /usr/local/include /usr/local/share && \
sudo chown -R \$(whoami) /usr/local/bin /usr/local/lib /usr/local/include /usr/local/share
RUN wget -q -O n https://raw.githubusercontent.com/tj/n/master/bin/n && \
bash n install 14.18.1
RUN npm install -g meteor
ENV PATH=\"/home/ubuntu/.meteor:\${PATH}\"
WORKDIR /home/ubuntu
"
echo "$dockerfile" | docker build -t meteor-ubuntu:2.5.1 -
docker run -it \
--rm \
-p 3000:3000 \
--entrypoint /bin/bash \
meteor-ubuntu:2.5.1 -c "meteor --version && \
meteor create --typescript myapp && \
cd myapp && \
NODE_ENV=production meteor --production"
```
Open http://localhost:3000 and see that “React is running in production mode, but dead code elimination has not been applied”
I also posted it here
https://forums.meteor.com/t/meteor-2-5-1-new-project-with-message-react-is-running-in-production-mode-but-dead-code-elimination-has-not-been-applied/57031/3