<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Daniel Medina</title>
    <description>The latest articles on DEV Community by Daniel Medina (@dwmedina).</description>
    <link>https://dev.to/dwmedina</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F97903%2F899be796-e618-411a-921f-8a979e47d5d0.jpg</url>
      <title>DEV Community: Daniel Medina</title>
      <link>https://dev.to/dwmedina</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/dwmedina"/>
    <language>en</language>
    <item>
      <title>My findings for a pytest-django warning - Error when trying to teardown test databases</title>
      <dc:creator>Daniel Medina</dc:creator>
      <pubDate>Mon, 08 Nov 2021 15:31:23 +0000</pubDate>
      <link>https://dev.to/dwmedina/my-findings-for-a-pytest-django-warning-error-when-trying-to-teardown-test-databases-48a5</link>
      <guid>https://dev.to/dwmedina/my-findings-for-a-pytest-django-warning-error-when-trying-to-teardown-test-databases-48a5</guid>
      <description>&lt;h2&gt;
  
  
  Background
&lt;/h2&gt;

&lt;p&gt;I found myself having a bit of free time on Friday the 5th so I thought it would be helpful to my team to try and decrease the amount of warnings we received after running tox and having all tests pass.&lt;/p&gt;

&lt;p&gt;Here was my environment:&lt;/p&gt;

&lt;p&gt;Ubuntu - 20.04 LTS&lt;br&gt;
django - 3.2.8&lt;br&gt;
pytest - 6.2.5&lt;br&gt;
pytest-django - 4.4.0&lt;br&gt;
tox - 3.24.4&lt;/p&gt;
&lt;h2&gt;
  
  
  Warning and Resolution
&lt;/h2&gt;

&lt;p&gt;I received a very strange / obscure warning whenever test databases would be torn down.  The warning in full was:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Error when trying to teardown test databases: TypeError('object.__new__() takes exactly one argument (the type to instantiate)')&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;I ended up resolving this warning by:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; Navigating to my &lt;code&gt;pytest.ini&lt;/code&gt; file in my base directory.&lt;/li&gt;
&lt;li&gt; On the &lt;code&gt;addopts&lt;/code&gt; line, adding two switches to the end:
&lt;code&gt;--reuse-db --create-db&lt;/code&gt; .&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The final version of this line looked like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[pytest]
// some other settings
addopts = [additional options here] --reuse-db --create-db 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Findings
&lt;/h2&gt;

&lt;p&gt;The source of this warning is from pytest-django's &lt;code&gt;fixtures.py&lt;/code&gt; file.  It can be found &lt;a href="https://github.com/pytest-dev/pytest-django/blob/master/pytest_django/fixtures.py"&gt;here on GitHub&lt;/a&gt; .  The function being called is &lt;code&gt;teardown_database&lt;/code&gt; which is defined on line 126.  &lt;/p&gt;

&lt;p&gt;According to pytest-django's official documentation, using the &lt;code&gt;reuse-db&lt;/code&gt; and &lt;code&gt;create-db&lt;/code&gt; switches together helps isolate and recreate databases throughout tests.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;--reuse-db will not pick up schema changes between test runs. You must run the tests with --reuse-db --create-db to re-create the database according to the new schema. Running without --reuse-db is also possible, since the database will automatically be re-created.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;(&lt;em&gt;source&lt;/em&gt;: &lt;a href="https://pytest-django.readthedocs.io/en/latest/database.html#reuse-db-reuse-the-testing-database-between-test-runs"&gt;pytest-django docs&lt;/a&gt;)&lt;/p&gt;

&lt;p&gt;My guess is that somewhere during the tests, not all of the test databases are properly created.  This would result in pytest-django trying to tear down something that isn't there.  This would also explain why it is looking for an object that can't be used when it is calling &lt;code&gt;teardown_database&lt;/code&gt; .&lt;/p&gt;

&lt;p&gt;Finally, in my time spent searching for a solution, I found some similar pages online.  While they weren't directly related to my problem and solution, they may be helpful in forming a trail of breadcrumbs towards solving a different problem:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://stackoverflow.com/questions/61465165/why-is-pytest-throwing-an-attributeerror-nonetype-object-has-no-attribute"&gt;SO - Why is pytest throwing an "Attribute Error: 'NoneType' object has no attribute..."&lt;/a&gt;&lt;br&gt;
&lt;a href="https://gist.github.com/raprasad/f292f94657728de45d1614a741928308"&gt;GitHub - Ignoring migrations during Django testing (unmanaged databases, legacy databases, etc)&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  References and Special Thanks
&lt;/h3&gt;

&lt;p&gt;I want to specifically thank Cris Ewing for their &lt;a href="https://tech.coffeemeetsbagel.com/testing-django-with-pytest-debugging-a-teardown-failure-acfa4103aa67"&gt;article on Medium&lt;/a&gt; .  I relied heavily on their troubleshooting and debugging methodology.  Without their post, I would never have found a solution or experimented using ideas from the official pytest-django documentation.  Thank you Cris!&lt;/p&gt;

&lt;p&gt;I also wish to thank Stefaan Lippens for their short blog post on how to disable PyTest's default log capturing.  It was very useful as I was debugging.  &lt;a href="https://www.stefaanlippens.net/pytest-disable-log-capturing.html"&gt;It can be found here&lt;/a&gt; .&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;References&lt;/strong&gt;:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://pytest-django.readthedocs.io/en/latest/database.html#reuse-db-reuse-the-testing-database-between-test-runs"&gt;pytest-django documentation --reuse-db reuse the test database between runs&lt;/a&gt;&lt;br&gt;
&lt;a href="https://github.com/pytest-dev/pytest-django"&gt;pytest-django source code&lt;/a&gt;&lt;/p&gt;

</description>
      <category>python</category>
      <category>django</category>
      <category>pytest</category>
    </item>
    <item>
      <title>How to install the psycopg2 Python package in WSL 2</title>
      <dc:creator>Daniel Medina</dc:creator>
      <pubDate>Fri, 30 Jul 2021 17:51:13 +0000</pubDate>
      <link>https://dev.to/dwmedina/how-to-install-the-psycopg2-python-package-in-wsl-2-11n</link>
      <guid>https://dev.to/dwmedina/how-to-install-the-psycopg2-python-package-in-wsl-2-11n</guid>
      <description>&lt;p&gt;This post is a quick note to all about how to install psycopg2 in Linux.  I used WSL 2 running Ubuntu 20.04.&lt;/p&gt;

&lt;h2&gt;
  
  
  Background
&lt;/h2&gt;

&lt;p&gt;I was trying to set up a toy project to learn Django using PostgreSQL.  When I tried to install the recommend psycopg2 package from pip, I received two error messages.&lt;/p&gt;

&lt;p&gt;The first error I received was:  &lt;strong&gt;error: invalid command 'bdist_wheel'&lt;/strong&gt; .  My second error was related to C / C++ and was in my log files:&lt;/p&gt;

&lt;p&gt;In file included from psycopg/adapter_asis.c:28:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;psycopg&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;psycopg&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;h&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;35&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;fatal&lt;/span&gt; &lt;span class="n"&gt;error&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;Python&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;h&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;No&lt;/span&gt; &lt;span class="n"&gt;such&lt;/span&gt; &lt;span class="n"&gt;file&lt;/span&gt; &lt;span class="n"&gt;or&lt;/span&gt; &lt;span class="n"&gt;directory&lt;/span&gt;
  &lt;span class="mi"&gt;35&lt;/span&gt;  &lt;span class="o"&gt;|&lt;/span&gt;  &lt;span class="err"&gt;#&lt;/span&gt;&lt;span class="n"&gt;include&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;Python&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;h&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="o"&gt;|&lt;/span&gt;           &lt;span class="o"&gt;^~~~~~~~~~&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;compilation terminated.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Steps
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt; I installed the following dependencies:  &lt;code&gt;python-dev&lt;/code&gt; , &lt;code&gt;python3-dev&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt; I installed wheels using  &lt;code&gt;pip3 install wheel&lt;/code&gt; .
&lt;/li&gt;
&lt;li&gt; I installed &lt;code&gt;python[your version]-dev&lt;/code&gt; using Ubuntu's &lt;code&gt;sudo&lt;/code&gt; command.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Explanation
&lt;/h2&gt;

&lt;p&gt;The root cause of the problem was that psycopg2 was looking for headers for Python 3.8.5.  Since I am using Python 3.9.5, the headers could not be located and psycopg2 could not install.  After installing &lt;code&gt;python3.9-dev&lt;/code&gt; , psycopg2 successfully installed on my system.&lt;/p&gt;

&lt;p&gt;I hope that this short post saves people time and energy.&lt;/p&gt;

&lt;p&gt;Additional references:  &lt;/p&gt;

&lt;p&gt;&lt;a href="https://stackoverflow.com/questions/34819221/why-is-python-setup-py-saying-invalid-command-bdist-wheel-on-travis-ci"&gt;SO - Invalid command bdist wheel on Travis CI&lt;/a&gt;&lt;br&gt;
&lt;a href="https://stackoverflow.com/questions/65273035/how-to-fix-error-invalid-command-bdist-wheel"&gt;SO - How to fix &lt;code&gt;error: invalid command 'bdist_wheel'&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>python</category>
      <category>wsl</category>
      <category>linux</category>
      <category>postgres</category>
    </item>
    <item>
      <title>Node.js server fails to render pages</title>
      <dc:creator>Daniel Medina</dc:creator>
      <pubDate>Sat, 01 Feb 2020 23:57:00 +0000</pubDate>
      <link>https://dev.to/dwmedina/node-js-server-fails-to-render-pages-41ie</link>
      <guid>https://dev.to/dwmedina/node-js-server-fails-to-render-pages-41ie</guid>
      <description>&lt;p&gt;Hello everyone!  I am trying to render two pages in a simple toy application to better understand Node.js and TypeScript.  The index page is supposed to display a simple message when going to &lt;code&gt;localhost:3000&lt;/code&gt; or &lt;code&gt;/&lt;/code&gt; while the 404 page is supposed to display an error message whenever an invalid URL is entered.&lt;/p&gt;

&lt;h3&gt;
  
  
  Error Message
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be one of type string, Buffer, or URL. Received type undefined&lt;br&gt;
    at Object.open (fs.js:406:10)&lt;/code&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Summary
&lt;/h3&gt;

&lt;p&gt;The two issues I am encountering are properly using the fs module's &lt;code&gt;readStream()&lt;/code&gt; method and absolute vs relative directory paths.&lt;/p&gt;
&lt;h3&gt;
  
  
  What I've already tried so far
&lt;/h3&gt;

&lt;p&gt;I've done a lot of Googling and found a lot of StackOverflow posts.  The majority that I have read are either relevant to other modules or are using &lt;code&gt;readFile()&lt;/code&gt;.  The only thing I've taken away from my searches is to use Node's &lt;code&gt;path&lt;/code&gt; module for resolving directory / file names.&lt;/p&gt;

&lt;p&gt;Additionally, I have tried using &lt;code&gt;console.log()&lt;/code&gt; to log my requests to the server and the path that &lt;code&gt;path.join()&lt;/code&gt; is reading. &lt;/p&gt;

&lt;p&gt;Here is my project structure:&lt;/p&gt;

&lt;p&gt;server_html (top level aka root directory)&lt;br&gt;
  -- node_modules&lt;br&gt;
  -- src&lt;br&gt;
    ↳ index.ts&lt;br&gt;
  -- views&lt;br&gt;
    ↳ 404.html&lt;br&gt;
    ↳ index.html&lt;br&gt;
  package-lock.json&lt;br&gt;
  package.json&lt;br&gt;
  prettier.config.json&lt;br&gt;
  tsconfig.json&lt;br&gt;
  tslint.json&lt;/p&gt;
&lt;h3&gt;
  
  
  Code Snippets
&lt;/h3&gt;

&lt;p&gt;Here are my imports, status codes, route map, and port:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="nx"&gt;http&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;http&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="nx"&gt;fs&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;fs&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="nx"&gt;path&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;path&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;httpOkStatus&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;number&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;httpNotFoundStatus&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;number&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;404&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;routeMap&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;any&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;/&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;path&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;__dirname&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;..&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;views&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;index.html&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;/index&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;path&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;__dirname&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;..&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;views&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;index.html&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;port&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;number&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;3000&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here's the code for my server:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;http&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;Server&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;http&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;createServer&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;http&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;IncomingMessage&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;http&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ServerResponse&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

        &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;writeHead&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;httpOkStatus&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Content-Type&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;text/html&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
        &lt;span class="p"&gt;});&lt;/span&gt;

        &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="na"&gt;pathToIndexView&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;routeMap&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;url&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
        &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="na"&gt;sendToErrorPage&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;boolean&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;routeMap&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;url&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;

        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;sendToErrorPage&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;writeHead&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;httpNotFoundStatus&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Content-Type&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;text/html&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
            &lt;span class="p"&gt;});&lt;/span&gt;
            &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="na"&gt;errorPageFileStream&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;fs&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ReadStream&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;fs&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;createReadStream&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;path&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;__dirname&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;..&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;views&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;404.html&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;utf8&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
            &lt;span class="nx"&gt;errorPageFileStream&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;pipe&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
            &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;end&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="na"&gt;src&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;fs&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ReadStream&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;fs&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;createReadStream&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;pathToIndexView&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;utf8&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

        &lt;span class="nx"&gt;src&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;pipe&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;end&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;listen&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;port&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`The server has started and is listening on port number: &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;port&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;FYI, my Index View is boilerplate HTML with a simple &lt;code&gt;&amp;lt;h1&amp;gt;Welcome!&amp;lt;/h1&amp;gt;&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Since the error is coming from &lt;code&gt;Object.open(fs.js:406:10)&lt;/code&gt;, my guess is that this error is happening within one of the &lt;code&gt;fs.createReadStream()&lt;/code&gt; methods.  The questions I have are:&lt;/p&gt;

&lt;p&gt;Why is the path to my Error page a type of &lt;code&gt;undefined&lt;/code&gt;?&lt;/p&gt;

&lt;p&gt;Why is my index page not rendering my message of "Welcome!"?&lt;/p&gt;

&lt;p&gt;Here are my logged paths for both my error page and my index page:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Error:  C:\Users\Daniel\Documents\TypeScript\serve_html\views\404.html
Index:  C:\Users\Daniel\Documents\TypeScript\serve_html\views\index.html
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Next Steps&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; I am going to go through &lt;a href="https://nodejs.org/api"&gt;Node's official API documentation&lt;/a&gt; to see what I can learn about the fs, path, and http modules.&lt;/li&gt;
&lt;li&gt; I may need to dig into the network traffic to see where my requests are going to.  I've already looked at some calls in Chrome's Network tab, but I am considering using separate tools to see all data paths.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;I'm new to Node.js and would appreciate even glances at this problem.  In the meantime, I will keep searching to find answers and / or stumble onto a working version of this.&lt;/p&gt;

</description>
      <category>help</category>
    </item>
  </channel>
</rss>
