<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Npm Archives - Conseil HU</title>
	<atom:link href="https://hyyyanick.com/category/npm/feed/" rel="self" type="application/rss+xml" />
	<link>https://hyyyanick.com/category/npm/</link>
	<description>Sharing, Growing</description>
	<lastBuildDate>Sun, 07 Dec 2025 10:33:26 +0000</lastBuildDate>
	<language>fr-FR</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.8.3</generator>
	<item>
		<title>Understanding the difference between npm install and npm ci</title>
		<link>https://hyyyanick.com/usage-of-npm-install-and-npm-ci/</link>
					<comments>https://hyyyanick.com/usage-of-npm-install-and-npm-ci/#respond</comments>
		
		<dc:creator><![CDATA[Yiyan HU]]></dc:creator>
		<pubDate>Sat, 06 Dec 2025 09:30:40 +0000</pubDate>
				<category><![CDATA[Angular]]></category>
		<category><![CDATA[Frontend]]></category>
		<category><![CDATA[Npm]]></category>
		<guid isPermaLink="false">https://hyyyanick.com/?p=1</guid>

					<description><![CDATA[<p>When working with a web developement projet, we may install packages and dependencies using npm install. However, there is another line of command npm ci that we may not be familiar with during local develepement. Personally, I found this command...</p>
<p>The post <a href="https://hyyyanick.com/usage-of-npm-install-and-npm-ci/">Understanding the difference between npm install and npm ci</a> appeared first on <a href="https://hyyyanick.com">Conseil HU</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>When working with a web developement projet, we may install packages and dependencies using <code><mark style="background-color:rgba(0, 0, 0, 0);color:#ff6a00" class="has-inline-color">npm install</mark></code>. However, there is another line of command <code><mark style="background-color:rgba(0, 0, 0, 0);color:#ff6a00" class="has-inline-color">npm ci</mark></code> that we may not be familiar with during local develepement. Personally, I found this command line in Gitlab CI/CD issue report which indicated that the dependencies in package-lock.json file is not synced with package.json. It is interesting to learn new things with an error. We will discuss the difference as below.</p>



<p class="has-medium-font-size">What <strong>npm install</strong> Actually Does</p>



<p><code><mark style="background-color:rgba(0, 0, 0, 0);color:#ff6a00" class="has-inline-color">npm install</mark></code> always begins by reading your <strong>package.json</strong> to determine what dependencies your project needs. If a <strong>package-lock.json</strong> is present, it treats it as a suggestion—but it updates the file as well after installing all dependencies.</p>



<p>I came into a situation where I should switch <strong>.npmrc</strong> configuration according to different projets. As I installed (npm install) dependencies with other npmrc setting, my package-lock.json was replaced and was not synced with package.json file. So the issue happened in Gitlab CI/CD (<strong>Angular peer dependency mismatch</strong> issue).</p>



<pre class="wp-block-code"><code><code>npm error <mark style="background-color:rgba(0, 0, 0, 0);color:#ff6a00" class="has-inline-color">npm ci can only install packages when your package.json and package-lock.json or npm-shrinkwrap.json are in sync</mark>. Please update your lock file with npm install before continuing. npm error npm error Missing: <strong>chokidar@3.6.0</strong> from lock file npm error npm error Clean install a project</code></code></pre>



<p class="has-medium-font-size">What <strong>npm ci</strong> Actually Does</p>



<p>This issue happens especially in CI/CD environnement where <code>npm ci</code> is strict about exact dependency versions. As the error indicates, my package.json and package-lock.json are not in sync. What <code>npm ci</code> does is that it uses <code>package-lock.json</code> as the single source of truth. It removes node_modules and <strong>reinstalls packages from scratch to guarantee a clean environnement</strong>. With npm ci, the installation is faster because it skips the dependency resolution and does not check node_modules cache.</p>



<p>To fix the issue, I should just remove node_modules and package-lock.json file in my local environnement, switching to the right npmrc setting and reinstall with npm install. But somehow it failed always&#8230;</p>



<p class="has-medium-font-size">What <strong>npm ls</strong> helps</p>



<p>This annoyed me a lot. But this problem let me discovered another command line &#8211; <code><mark style="background-color:rgba(0, 0, 0, 0);color:#ff6a00" class="has-inline-color">npm ls</mark></code>. With <code>npm ls chokidar</code>, it output this error:</p>



<pre class="wp-block-code"><code>+-- @angular-devkit/build-angular@20.3.10 | +-- @angular-devkit/core@20.3.10 | | <code>-- chokidar@4.0.3 deduped </code>| +-- sass@1.90.0 | | <code>-- chokidar@4.0.3 deduped </code>| <code>-- webpack-dev-server@5.2.2 </code>| <code>-- chokidar@3.6.0 </code>+-- @angular/compiler-cli@20.3.11 | <code>-- chokidar@4.0.3 </code>+-- @schematics/angular@13.3.11 | <code>-- @angular-devkit/core@13.3.11 </code>| <code>-- chokidar@4.0.3 deduped invalid: "^3.5.2" from node_modules/@schematics/angular/node_modules/@angular-devkit/core -- karma@6.4.4</code> <code>-- chokidar@3.6.0</code>
npm error code ELSPROBLEMS 
npm error invalid: chokidar@4.0.3</code></pre>



<p>So it is clear that the chokidar version is not compatible. I fixed the chokidar version manuelly in my package.json file, removing node_modules and package-lock.json, and reinstalled all packages. Now when I checked with <code><mark style="background-color:rgba(0, 0, 0, 0);color:#ff6a00" class="has-inline-color">npm ls</mark></code>, no more conflits in dependencies installed.</p>
<p>The post <a href="https://hyyyanick.com/usage-of-npm-install-and-npm-ci/">Understanding the difference between npm install and npm ci</a> appeared first on <a href="https://hyyyanick.com">Conseil HU</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://hyyyanick.com/usage-of-npm-install-and-npm-ci/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
