<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Elijah Manor on Medium]]></title>
        <description><![CDATA[Stories by Elijah Manor on Medium]]></description>
        <link>https://medium.com/@elijahmanor?source=rss-a664563eb13a------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*hTy_jbyA6TvT1TcsEDFkMw.jpeg</url>
            <title>Stories by Elijah Manor on Medium</title>
            <link>https://medium.com/@elijahmanor?source=rss-a664563eb13a------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 18 Nov 2026 21:06:47 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@elijahmanor/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Reusable State and Effects with React Hooks]]></title>
            <link>https://medium.com/@elijahmanor/reusable-state-and-effects-with-react-hooks-a57f0729efeb?source=rss-a664563eb13a------2</link>
            <guid isPermaLink="false">https://medium.com/p/a57f0729efeb</guid>
            <category><![CDATA[react]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Elijah Manor]]></dc:creator>
            <pubDate>Mon, 10 Dec 2018 07:09:25 GMT</pubDate>
            <atom:updated>2018-12-10T07:09:25.726Z</atom:updated>
            <content:encoded><![CDATA[<p>13 Oct 2018</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*UwAYd9xQRgbmIcoZ.png" /></figure><p>Today my latest <a href="https://egghead.io/">Egghead.io</a> course has launched entitled, <a href="https://egghead.io/courses/reusable-state-and-effects-with-react-hooks">Reusable State and Effects with React Hooks</a>.</p><p>Previously, in order to add state or side-effects in React you had to create a Class Component. However, with the introduction of the Hooks proposal (currently pre-released), you can now add state and effects to a Function Component.</p><p>In addition, you can extract your hook logic and create a custom hook that can be shared across your app.</p><blockquote>🆓 The <a href="https://egghead.io/courses/reusable-state-and-effects-with-react-hooks">Reusable State and Effects with React Hooks</a> course is currently free to watch until Sunday December 16th. So, watch today!</blockquote><h3>Course Introduction</h3><p>In the <a href="https://egghead.io/lessons/react-introduction-to-reusable-state-and-effects-with-react-hooks">following video</a> (click the video to play) I introduce the course and explain what you can expect by watching the 12 lessons. The lessons are faced paced and the whole course lasts about an hour long. You could probably watch the entirety of the course over lunch or maybe convince your boss to watch it during work time.</p><figure><a href="https://egghead.io/lessons/react-introduction-to-reusable-state-and-effects-with-react-hooks"><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_IKTHtOLk9ronXszBHLmbw.png" /></a></figure><h3>Lessons</h3><p>The following 12 lessons are included in the React Hooks <a href="https://egghead.io/courses/reusable-state-and-effects-with-react-hooks">course</a>.</p><ul><li>Environment Setup for React Hooks</li><li>Add State with the useState Hook to a React Function Component</li><li>Add Linting to Help Enforce Rules when Using React Hooks</li><li>Add a Lifecycle Event with the useEffect Hook to a React Function Component</li><li>Use the React useRef Hook to Reference a DOM Element or Simulate an Instance Variable</li><li>Write Custom Hooks to Share Logic Between React Function Components</li><li>Leverage an Existing Community Hook in Your React Function Component</li><li>Use the useReducer Hook and Dispatch Actions to Update State</li><li>Use the useContext Hook to Wire-up the React Context API</li><li>Simulate PureComponent with a React Function Component</li><li>Leverage the React useMemo Hook for Expensive Operations</li><li>Convert a Render Props Component using a Custom React Hook</li></ul><h3>Conclusion</h3><p>I hope you enjoy the course and find something useful that you can start using in your projects. Remember, you can watch the whole course free for a week!</p><p><em>Originally published at </em><a href="https://elijahmanor.com/react-hooks-course/"><em>elijahmanor.com</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a57f0729efeb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Learn about the npx Package Runner]]></title>
            <link>https://medium.com/@elijahmanor/learn-about-the-npx-package-runner-769f6e0bc404?source=rss-a664563eb13a------2</link>
            <guid isPermaLink="false">https://medium.com/p/769f6e0bc404</guid>
            <category><![CDATA[npm]]></category>
            <category><![CDATA[npx]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Elijah Manor]]></dc:creator>
            <pubDate>Wed, 14 Nov 2018 04:22:12 GMT</pubDate>
            <atom:updated>2018-11-19T14:33:55.670Z</atom:updated>
            <content:encoded><![CDATA[<h3>Free Video Course on npx: the npm Package Runner</h3><p>13 Oct 2018</p><figure><a href="https://egghead.io/courses/execute-npm-package-binaries-with-the-npx-package-runner"><img alt="" src="https://cdn-images-1.medium.com/max/800/0*wnpbksec2D5hxSki.png" /></a></figure><p>Last week my latest <a href="https://egghead.io/">Egghead.io</a> course was launched entitled, <a href="https://egghead.io/courses/execute-npm-package-binaries-with-the-npx-package-runner">Execute npm Package Binaries with the npx Package Runner</a>.</p><p><a href="https://www.npmjs.com/package/npx">npx</a> is a tool that comes baked in <a href="https://www.npmjs.com/">npm</a> (if you have version 5.2 or above), that you may or may not know about. It’s a handy little utility that enables you to play around with node packages in a way that wasn’t really easy before.</p><p>I find myself using npx all the time. It’s a tool I use most days.</p><blockquote><em>This course is now available </em>as a 🆓 Community Resource on Egghead.io. So, feel free to watch at your own pace.</blockquote><h3>Lessons</h3><p>The following lessons are included in the npx <a href="https://egghead.io/courses/execute-npm-package-binaries-with-the-npx-package-runner">course</a>. For those that regularly use npm and npm scripts, lessons 1 and 2 are big improvements to your command-line workflow. Lessons 3 through 7 focus on uncovering some lesser known features of npx that I find are useful.</p><ol><li><a href="https://egghead.io/lessons/npm-use-npx-to-run-locally-installed-node-modules">Use npx to run locally installed node modules</a></li><li><a href="https://egghead.io/lessons/npm-use-npx-to-temporarily-install-and-invoke-a-package-from-npm">Use npx to Temporarily Install and Invoke a Package from npm</a></li><li><a href="https://egghead.io/lessons/npm-test-different-node-module-versions-with-npx">Test Different Node Module Versions with npx</a></li><li><a href="https://egghead.io/lessons/npm-use-npx-to-run-commands-with-different-node-js-versions">Use npx to run commands with different Node.js versions</a></li><li><a href="https://egghead.io/lessons/npm-execute-npx-commands-with-npm_-environment-variables">Execute npx commands with $npm_ Environment Variables</a></li><li><a href="https://egghead.io/lessons/npm-execute-code-from-a-remote-github-branch-with-npx">Execute Code from a Remote GitHub Branch with npx</a></li><li><a href="https://egghead.io/lessons/npm-use-npx-to-execute-code-from-a-github-gist">Use npx to execute code from a GitHub gist</a></li></ol><h3>Having Fun with npx</h3><p>As I teach npx I also try to keep things fun and faced paced. The following GIF shows a small clip from the 2nd lesson, <a href="https://egghead.io/lessons/npm-use-npx-to-temporarily-install-and-invoke-a-package-from-npm">Use npx to Temporarily Install and Invoke a Package from npm</a>, where I experiment with various packages without installing them globally.</p><p>Who knew <a href="https://npm.im/devpun">devpun</a>, <a href="https://npm.im/cowsay">cowsay</a>, and <a href="https://npm.im/lolcatjs">lolcatjs</a> could be so fun!?!</p><figure><a href="https://egghead.io/lessons/npm-use-npx-to-temporarily-install-and-invoke-a-package-from-npm"><img alt="" src="https://cdn-images-1.medium.com/max/890/1*Ia-iOckFEcZ-d3aieJ8r6Q.gif" /></a></figure><h3>Course Reviews</h3><p>Some reviews have already started coming in for this course. The following is a taste of what some are saying thus far.</p><blockquote><em>“So many great little tips! Plus it was short and easily-digestible. Lots of this is immediately-applicable to our team, and lots of it is fun to know.”</em></blockquote><blockquote><em>“I seriously had no idea </em><em>npx was capable of so much. Nicely done!”</em></blockquote><blockquote><em>“Elijah’s instructions are clear, sufficiently detailed and unambigous. I can’t wait to put my learning to good use. Thanks a lot for this wonderful course.”</em></blockquote><blockquote><em>“The course contains a lot of useful information and the presentation of the instructor is engaging. Thank you!”</em></blockquote><blockquote>“Nice simple tutorial about npx. Before npx was a magical tool for me, but now I understand why we need it.”</blockquote><h3>Conclusion</h3><p>I hope you enjoy the course and find something useful that you can start using in your projects.</p><p><em>Originally published at </em><a href="https://elijahmanor.com/npx-course/"><em>elijahmanor.com</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=769f6e0bc404" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What’s New in Create React App 2.0 Video Series]]></title>
            <link>https://medium.com/@elijahmanor/whats-new-in-create-react-app-2-0-video-series-4ffaaa7cb7df?source=rss-a664563eb13a------2</link>
            <guid isPermaLink="false">https://medium.com/p/4ffaaa7cb7df</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[create-react-app]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[css]]></category>
            <dc:creator><![CDATA[Elijah Manor]]></dc:creator>
            <pubDate>Thu, 11 Oct 2018 07:59:44 GMT</pubDate>
            <atom:updated>2018-10-12T19:20:24.800Z</atom:updated>
            <content:encoded><![CDATA[<p>11 Oct 2018</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8bKG9In65xFg-rBQLGy7Aw.png" /></figure><p>Earlier this month <a href="https://reactjs.org/blog/2018/10/01/create-react-app-v2.html">Create React App 2.0</a> was released adding a lot of new features. Some of those features include Sass Support, CSS Modules Support, Adding SVGs as React Components, Fragment Short Syntax, and Babel Macros. In this post, I’ll be highlighting the above 5 features. For a complete list of all the features of Create React App 2.0 please check out the official post on the <a href="https://reactjs.org/blog/2018/10/01/create-react-app-v2.html">React Blog</a>.</p><blockquote>To quickly watch all the free Egghead.io video lessons described in this post, you can go directly to the <a href="https://egghead.io/playlists/create-react-app-2-0-1218245e">Create React App 2.0 Playlist</a>.</blockquote><h3>Adding Sass Support</h3><h3>𝙴𝚕𝚒𝚓𝚊𝚑 𝙼𝚊𝚗𝚘𝚛 on Twitter</h3><p>🎥 Add Sass Support to Create React App 2.0 1️⃣ npm init react-app myapp &amp;amp;&amp;amp; cd $_ 2️⃣ code . &amp;amp;&amp;amp; npm start 3️⃣ import &quot;./ReactLink.scss&quot;; 4️⃣ error displayed with install instructions 5️⃣ npm i node-sass --save 6️⃣ app now supports sass 🆓 https://t.co/yaBHbhhziV</p><p>Previously Create React App 1.x did not support any CSS preprocessor out-of-the box, such as <a href="https://sass-lang.com/">Sass</a>, LESS, Stylus, or PostCSS.</p><p>Therefore, developers were left to either…</p><ol><li>Use native CSS</li><li>Manually run a CSS preprocessor outside the normal CRA build flow</li><li>Eject their project with npm run eject and add webpack support for a CSS preprocessor</li><li>Use <a href="https://github.com/timarney/react-app-rewired">react-app-rewired</a> to get around ejecting CRA</li><li>Use a CSS-in-JS solution such as <a href="https://github.com/emotion-js/emotion">emotion</a>, etc…</li></ol><p>However, with Create React App 2.0 you can now use Sass, although it doesn’t come out-of-the box exactly. Once you do import a Sass file, then CRA will display a detailed error message guiding you to install …</p><p>One of the new features is support for <a href="https://sass-lang.com/">Sass</a>. If you start to use Sass, create-react-app will give you an error, but will display the following detailed error on how you can add Sass support to your project.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*GdMjoDHxCcBn0xrt.png" /></figure><p>At that point, you can npm i node-sass --save and restart your dev server for Sass support!</p><p>You can watch the following free <a href="https://egghead.io/lessons/react-add-sass-support-to-create-react-app-2-0">2:30 minute Egghead.io video</a> of me demonstrating this feature.</p><p><a href="https://egghead.io/lessons/react-add-sass-support-to-create-react-app-2-0">Add Sass Support to Create React App 2.0</a></p><h3>CSS Modules Support</h3><h3>𝙴𝚕𝚒𝚓𝚊𝚑 𝙼𝚊𝚗𝚘𝚛 on Twitter</h3><p>🎥 Use CSS Modules with Create React App 2.0 1️⃣ npm init react-app myapp &amp;amp;&amp;amp; cd $_ 2️⃣ import styles from &quot;./Link.module.css&quot;; 3️⃣ use locally scoped class names off of styles 🗒 Name of CSS Module must match *.module.css format 🆓 https://t.co/1Yinks8oY6</p><p>As I mentioned above, other than native CSS support, Create React App 1.x didn’t support many other styling options out-of-the-box. Another popular styling technique that mirrors the idea of React Components is called CSS Modules.</p><p>CSS Modules is a very powerful technique because it automatically scopes class names and animation names in a local way in order to get around the problem of global class name clashes. You can learn more by looking at the <a href="https://github.com/css-modules/css-modules">CSS Modules repository</a>.</p><p>With CSS Modules you do not have to install any other dependencies like is necessary with Sass Support. In order to opt-in to CSS Modules, you need to follow the naming convention of *.module.css. The following file is named Link.module.css and defines the classes .default, .warning, and .error. You may notice a couple of things that are unique to this file…</p><ol><li>The class names are very terse and specific to the file. Since the class names are local there is no need to follow a rigid naming formation like BEM, for example.</li><li>Much like you compose Components in React, you can also use composes in CSS Modules to build up styles. The following .warning class takes the styles from .default and adds it’s own styles to it color and background-color.</li></ol><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f19bc8fe3d032d8488435553d6513ed9/href">https://medium.com/media/f19bc8fe3d032d8488435553d6513ed9/href</a></iframe><p>Once you import the CSS Module, you save off the default export for use inside your React Component. For example, mode could have values of default, warning, and error that match the class names from the Link.module.css imported file.</p><blockquote><em>NOTE: The reason these classes are considered local is because dynamic class names are generated for them. If you were to look at your browser’s DevTools you’d see class names that semi-resemble the name you called them.</em></blockquote><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d6078aa153a9d9333269d804eff363d2/href">https://medium.com/media/d6078aa153a9d9333269d804eff363d2/href</a></iframe><p>You can watch the following free <a href="https://egghead.io/lessons/react-use-css-modules-with-create-react-app-2-0">2:57 minute Egghead.io video</a> of me demonstrating this feature.</p><p><a href="https://egghead.io/lessons/react-use-css-modules-with-create-react-app-2-0">Use CSS Modules with Create React App 2.0</a></p><h3>Adding SVGs as React Components</h3><h3>𝙴𝚕𝚒𝚓𝚊𝚑 𝙼𝚊𝚗𝚘𝚛 on Twitter</h3><p>🎥 Add SVGs as React Components with Create React App 2.0 1️⃣ npm init react-app myapp &amp;amp;&amp;amp; cd $_ 2️⃣ import logo, { ReactComponent as ReactLogo } from &#39;./logo.svg&#39;; 3️⃣ render &amp;lt;ReactLogo /&amp;gt; 4️⃣ inline SVG for the win! 5️⃣ use CSS to style SVG 🆓 https://t.co/rz0xdrasI8 https://t.co/GY366MfDo4</p><p>Previously in Create React App 1.x when you wanted to import a SVG you would be grabbing the filename and using that as the source of an image. This was a workable solution, but now with Create React App 2.0 you can also optionally render a Component version of the SVG.</p><p>You might be wondering why this is such a big deal. Well, the Component version of the SVG renders as an inline SVG, which opens up the possibility of styling the various parts of the SVG.</p><p>So, for example, in the following CSS snippet I dive into the .App-logo and style the g element to be salmon in color. And then, I go one step further to animate the path&#39;s stroke!</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/09d743943f69a18d0e2df01eac67059e/href">https://medium.com/media/09d743943f69a18d0e2df01eac67059e/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/743/0*d2zrtOStaT80kFB7.gif" /></figure><blockquote><em>NOTE: The following snippet only show the extra bit of CSS I added to style the nested elements of the SVG. In case you were wondering, I omitted the styles that rotate the logo.</em></blockquote><p>You can watch a free <a href="https://egghead.io/lessons/react-add-svgs-as-react-components-with-create-react-app-2-0">2:26 minute Egghead.io video</a> of me demonstrating this feature.</p><p><a href="https://egghead.io/lessons/react-add-svgs-as-react-components-with-create-react-app-2-0">Add SVGs as React Components with Create React App 2.0</a></p><h3>Use the Fragment Short Syntax</h3><h3>𝙴𝚕𝚒𝚓𝚊𝚑 𝙼𝚊𝚗𝚘𝚛 on Twitter</h3><p>🎥 Use the Fragment Short Syntax in Create React App 2.0 1️⃣ npm init react-app myapp &amp;amp;&amp;amp; cd $_ 2️⃣ try &amp;lt;React.Fragment&amp;gt; 3️⃣ import React, { Fragment } from &quot;react&quot;; 4️⃣ try &amp;lt;Fragment&amp;gt; 5️⃣ try &amp;lt;&amp;gt; 🗒 CRA uses Babel 7+ which supports the Short Syntax 🆓 https://t.co/Uw7Md2paHH https://t.co/0MnFLevNP2</p><p>One of the new underlying features of Create React App 2.0 is upgrading to Babel Version 7, which enables the Short Syntax of React Fragments. You might be thinking, “Wait, weren’t Fragments added back in React 16.2?”. If that is what you were thinking, you’d be completely right! However, the Short Syntax of Fragment has only been available since Babel 7.0. As a refresher, Fragments let you wrap a group of React children without adding an extra parent node to the DOM, which is helpful if you need to maintain a specific DOM structure. So, in the following code snippet, instead of using &lt;React.Fragment&gt;&lt;/React.Fragment&gt; or &lt;Fragment&gt;&lt;/Fragment&gt;, since Create React App 2.0 uses Babel 7.0+, you can leverage the Fragment Short Syntax of &lt;&gt;&lt;/&gt; instead. Yes, it looks kind of strange to begin with, but I’ve started to get used to it.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a9682f72d52b62194be49cc760acc250/href">https://medium.com/media/a9682f72d52b62194be49cc760acc250/href</a></iframe><p>You can watch a free <a href="https://egghead.io/lessons/react-use-the-fragment-short-syntax-in-create-react-app-2-0">2:56 minute Egghead.io video</a> of me demonstrating this feature.</p><p><a href="https://egghead.io/lessons/react-use-the-fragment-short-syntax-in-create-react-app-2-0">Use the Fragment Short Syntax in Create React App 2.0</a></p><h3>Babel Macros Support</h3><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2F1ERAJG9ILhk%3Ffeature%3Doembed&amp;url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D1ERAJG9ILhk&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2F1ERAJG9ILhk%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/9d3cd284265bf95c54c6623abfcfc657/href">https://medium.com/media/9d3cd284265bf95c54c6623abfcfc657/href</a></iframe><p>Since Create React App doesn’t let you change it’s configuration (unless you eject or use <a href="https://github.com/timarney/react-app-rewired">react-app-rewired</a>), the addition of <a href="https://www.npmjs.com/package/babel-plugin-macros">Babel Macros</a> to Create React App 2.0 was a welcome feature that opens up the ability to tap into Babel code transformations without tweaking babel’s configuration.</p><p>Feel free to watch the above video by <a href="https://twitter.com/kentcdodds">Kent C. Dodds</a>, check out the <a href="https://www.npmjs.com/package/babel-plugin-macros">official repository documentation</a>, and read a detailed blog post by Kent entitled <a href="https://blog.kentcdodds.com/how-writing-custom-babel-and-eslint-plugins-can-increase-your-productivity-and-improve-user-fd6dd8076e26">How writing custom Babel &amp; ESLint plugins can increase productivity &amp; improve user experience</a>. I also plan to have an Egghead.io video covering Babel Macros in the near future, but in the meantime the above material should get you up-to-speed.</p><h3>Conclusion</h3><p>There’s so much more to the Create React App 2.0 release than just the items above. For more features, I encourage you to check out the official post on the <a href="https://reactjs.org/blog/2018/10/01/create-react-app-v2.html">React Blog</a>.</p><p><em>Originally published at </em><a href="https://elijahmanor.com/cra2-playlist/"><em>elijahmanor.com</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4ffaaa7cb7df" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Create a project using the `npm init initializer` command]]></title>
            <link>https://medium.com/@elijahmanor/create-a-project-using-the-npm-init-initializer-command-3ffa4e0ce2f?source=rss-a664563eb13a------2</link>
            <guid isPermaLink="false">https://medium.com/p/3ffa4e0ce2f</guid>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[npm]]></category>
            <dc:creator><![CDATA[Elijah Manor]]></dc:creator>
            <pubDate>Thu, 11 Oct 2018 05:50:24 GMT</pubDate>
            <atom:updated>2018-10-11T05:50:24.876Z</atom:updated>
            <content:encoded><![CDATA[<p>18 Sep 2018</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*M5koZU8nfCa_rLeCjcJ_0w.png" /></figure><blockquote>You can watch a free short 4:05 minute video about the following content hosted on <a href="https://egghead.io/lessons/react-create-a-new-project-using-the-npm-init-initializer-command">egghead.io</a>.</blockquote><p>Historically, the <a href="https://docs.npmjs.com/cli/init">npm init</a> command was solely used to create a new package.json file. However, as of version 6.1.0, you can use a new feature of npm init called the &lt;initializer&gt;. The initializer you provide will determine how your new application will be built. npm will prepend create- to the name of the initializer you provide and use npx to temporarily install and execute that project.</p><h3>3 ways to create-react-app with npm</h3><p>Depending on what version of npm you have installed, there are various ways to interact with npm packages. In order to see these differences, let’s focus on interacting with the <a href="https://github.com/facebook/create-react-app">create-react-app</a> package to bootstrap a React application.</p><h3>1. npm &lt;= 5.1.0</h3><p>If you have a older version of npm (less than or equal to 5.1.0), then you don’t have many options when using create-react-app. You are basically constrained to globally installing creat-react-app and then using it to bootstrap your app.</p><pre>npm install create-react-app -g create-react-app playground</pre><p>The above will globally install the create-react-app from the npm registry and then utilize the global package to bootstrap the application.</p><h4>Pros</h4><ul><li>This will work with any version of npm</li><li>Once installed, you don’t have to reinstall</li></ul><h4>Cons</h4><ul><li>The version of create-react-app may get out of date</li></ul><h3>2. npm &gt;= 5.2.0</h3><p>If you have a version of npm equal to or greater than 5.2.0, then you can use the npx tool that comes bundled with npm.</p><p>npx (among other things) will temporarily install a package if it’s not already installed globally. This is great if you want to experiment with a package or, if you run it so infrequently, you’d rather always have the latest version.</p><pre>npx create-react-app playground</pre><p>The above snippet will temporarily install create-react-app from the npm registry and then execute it in order to bootstrap the application.</p><h4>Pros</h4><ul><li>You always have the latest version</li><li>You don’t have to install the package globally</li></ul><h4>Cons</h4><ul><li>It’s not as fast as using a globally installed package</li></ul><h3>3. npm &gt;= 6.1.0</h3><p>Finally, if you have a fairly recent version of npm (version 6.1.0 or above), then you have the newest way to initialize an app. The npm init command has been around for many years, but as of 6.1.0 there is a new &lt;initializer&gt; option that let’s npm know you’d like to use it to create or update your app.</p><p>Under the covers npm will prepend create- to the initializer you provide and then install and execute it with the npx tool (as we discussed up above).</p><pre>npm init react-app playground</pre><p>The above snippet will go out and find the create-react-app from the npm registry and then install and execute it with npx in order to bootstrap the application.</p><h4>Pros</h4><ul><li>It’s semantic since you are initializing a project</li><li>It’s a few characters shorter than calling npx directly</li><li>You always have the latest version</li><li>You don’t have to install the package globally</li></ul><h4>Cons</h4><ul><li>It’s not as fast as using a globally installed package</li></ul><h3>Other create-&lt;initializers&gt;</h3><p>Above we looked at create-react-app, as an example, but there many are other initializers you can use as well, such as…</p><ul><li><a href="https://www.npmjs.com/package/create-deck">create-deck</a> - Create mdx-deck presentations</li><li><a href="https://github.com/CVarisco/create-component-app">create-component-app</a> - Tool to generate different types of React components from the terminal. 💻</li><li><a href="https://github.com/webhintio/hint">create-hintrc</a> - 💡 A hinting engine for the web <a href="https://webhint.io/">https://webhint.io/</a></li><li><a href="https://npm.im/create-esm">create-esm</a> - Create esm enabled packages</li></ul><p>What is your favorite initializer? If you use one that isn’t on the above list, I’d love to know. Please let me know on Twitter at <a href="https://twitter.com/elijahmanor">@elijahmanor</a>!</p><h3>Conclusion</h3><p>Depending on your version of your npm, you can create projects in very different ways. If you have the latest version, you can use all 3 of the above techniques, including the new initializer option.</p><p><em>Originally published at </em><a href="https://elijahmanor.com/npm-init-initializer/"><em>elijahmanor.com</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3ffa4e0ce2f" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>