<p>I had a express application and I used this application in my Kubernetes cluster.</p>
<p>This application is auth service for my micro service architecture study.</p>
<p>I use Skaffold dev command for applying Kubernetes for this app.</p>
<p>My Dockerfile is like that:</p>
<pre><code>FROM node:alpine

WORKDIR /app
COPY package.json .
RUN npm install

COPY . .

CMD [&quot;npm&quot;, &quot;start&quot;]
</code></pre>
<p>And I run it with &quot;Scaffold dev&quot; command</p>
<p>And I getting error like that:</p>
<pre><code>...
...    
Deployments stabilized in 3.752 seconds
Watching for changes...
[auth] npm notice 
[auth] npm notice New patch version of npm available! 7.5.1 -&gt; 7.5.4
[auth] npm notice Changelog: &lt;https://github.com/npm/cli/releases/tag/v7.5.4&gt;
[auth] npm notice Run `npm install -g npm@7.5.4` to update!
[auth] npm notice 
[auth] npm ERR! path /app
[auth] npm ERR! command failed
[auth] npm ERR! signal SIGTERM
[auth] npm ERR! command sh -c node server.js
[auth] 
[auth] npm ERR! A complete log of this run can be found in:
[auth] npm ERR!     /root/.npm/_logs/2021-02-19T16_46_28_956Z-debug.log
</code></pre>
<p>And my package.json file :</p>
<pre><code>    {
  &quot;name&quot;: &quot;authservice&quot;,
  &quot;version&quot;: &quot;1.0.0&quot;,
  &quot;description&quot;: &quot;Auth Service&quot;,
  &quot;main&quot;: &quot;index.js&quot;,
  &quot;scripts&quot;: {
    &quot;test&quot;: &quot;echo \&quot;Error: no test specified\&quot; &amp;&amp; exit 1&quot;,
    &quot;start&quot;: &quot;node server.js&quot;
  },
  &quot;keywords&quot;: [
    &quot;auth&quot;,
    &quot;user&quot;
  ],
  &quot;author&quot;: &quot;&quot;,
  &quot;license&quot;: &quot;ISC&quot;,
  &quot;dependencies&quot;: {
    &quot;bcrypt&quot;: &quot;^5.0.0&quot;,
    &quot;body-parser&quot;: &quot;^1.19.0&quot;,
    &quot;dotenv&quot;: &quot;^8.2.0&quot;,
    &quot;express&quot;: &quot;^4.17.1&quot;,
    &quot;express-rate-limit&quot;: &quot;^5.2.3&quot;,
    &quot;jsonwebtoken&quot;: &quot;^8.5.1&quot;,
    &quot;mongoose&quot;: &quot;5.10.19&quot;,
    &quot;morgan&quot;: &quot;^1.10.0&quot;,
    &quot;multer&quot;: &quot;^1.4.2&quot;
  },
  &quot;devDependencies&quot;: {
    &quot;nodemon&quot;: &quot;^2.0.6&quot;
  }
}
</code></pre>
<p>How can I solve this error?</p>

akasaa
<p>I assume you're either incorrectly specifying your script in the <code>package.json</code> or your script is not <code>server.js</code>.</p>
<p>A minimal repro of your question works:</p>
<p>Using the Node.JS Getting Started guide's example with one minor tweak:
<a href="https://nodejs.org/en/docs/guides/getting-started-guide/" rel="nofollow noreferrer">https://nodejs.org/en/docs/guides/getting-started-guide/</a></p>
<blockquote>
<p><strong>NOTE</strong> Change <code>const hostname = '127.0.0.1';</code> to <code>const hostname = '0.0.0.0';</code> This is necessary to access the containerized app from the host.</p>
</blockquote>
<p>Adding a package.json because you have one and to show <code>npm start</code>:</p>
<p><code>package.json</code>:</p>
<pre><code>{
    &quot;name&quot;: &quot;66281738&quot;,
    &quot;version&quot;: &quot;0.0.1&quot;,
    &quot;scripts&quot;: {
        &quot;start&quot;: &quot;node app.js&quot;
    }
}
</code></pre>
<blockquote>
<p><strong>NOTE</strong> I believe <code>npm start</code> defaults to <code>&quot;start&quot;: &quot;node server.js&quot;</code></p>
</blockquote>
<p>Using your <code>Dockerfile</code> and:</p>
<pre class="lang-sh prettyprint-override"><code>QUESTION=&quot;66281738&quot;
docker build --tag=${QUESTION} --file=./Dockerfile .
docker run --interactive --tty --publish=7777:3000 ${QUESTION}
</code></pre>
<p>Yields:</p>
<pre><code>&gt; 66281738@0.0.1 start
&gt; node app.js

Server running at http://0.0.0.0:3000/
</code></pre>
<blockquote>
<p><strong>NOTE</strong> <code>docker run</code> binds the container's <code>:3000</code> port to the host's <code>:7777</code> just to show these need not be the same.</p>
</blockquote>
<p>Then:</p>
<pre class="lang-sh prettyprint-override"><code>curl --request GET http://localhost:3000/
</code></pre>
<p>Yields:</p>
<pre><code>Hello World
</code></pre>
