How to run: X-Press Publishing in 2020 [SOLVED]

X-Press Publishing

when you open provided zip file, you realize the files are from far 2017, the main reason that
npm install - fails
because in 2020 most of us are using newer versions of node (my node v. 12.16.3),
and this ol boy runs perfectly on node 9.0.0 from 2017-10-31. so you need to downgrade your node to older version. Thankfully we have nvm tool for easy switch between versions. In terminal run:
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash
(but as aware user, always examine .sh files before opening them)
now run, to test if the nvm was installed
command -v nvm
#expected output: nvm

if command -v nvm not returning nvm , edit your ~/.bashrc or ~/.zshrc,
by adding next

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  # This loads nvm bash_completion

that should work, if not I’ll leave the article.

in your IDE, open unzipped folder with project, open terminal IDE and in root type:
node -v
will return your current node version

nvm install 9.0.0
will install node 9.0.0 from 2017-10-31

node -v
now you are on 9.0.0

npm i
now you have all the packets with no no errors this time :slight_smile: & no package.JSON edits

image

you’ll take it from here :wave:

9 Likes

Hey, thank you for the guide! Before changing the node version, you can have a look at the modules in package.json and change their version-number to the newest version. The main problem with X-Press seems to be Sqlite3.

1 Like

Downgrading to node v8.11.3 did the trick for me. Thanks for the tip!

1 Like

I wasn’t able to “run” the wget command in my terminal (neither in MacBook’s bash one nor in VisualStudioCode’s terminal).
So I found this solution on stackoverflow that worked for me:

 curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash
 sudo npm install -g n
 sudo n 9.0.0
 npm install
 npm audit fix
 npm start

available here: https://stackoverflow.com/questions/47008159/how-to-downgrade-node-version (from Hariharan AR)

1 Like

I “solved” this issue by using a compatible version of sqlite3. At this time (7/2020), my verison of Node is v14.3.0, which is only compatible with sqlite3 v5.0.0, so I ran ‘npm install sqlite3@5.0.0’ to set it up.

This works and allows you to do the project and pass all the testing, but it does seem these newer versions aren’t compatible with the old front end code, as the website itself is completely broken and non-responsive. The backend for this project does work correctly though as you can access the API endpoints and trigger the GET routes directly from a browser. For example, browsing to:

http://localhost:4001/api/series/2/issues

Will display: (from the seeded data)

{“issues”:[{“id”:1,“name”:“The Customizable BashMan”,“issue_number”:1,“publication_date”:“January 1, 1990”,“artist_id”:2,“series_id”:2},{“id”:2,“name”:“BashMan Meets ScareCurl”,“issue_number”:2,“publication_date”:“January 8, 1990”,“artist_id”:2,“series_id”:2}]}

Hope Codecademy starts updating their content to resolve these issues.

Hey, I also did this project in June, and I solved the same issue by running the command npm install --unsafe-perm -g sqlite3 then updating package.json dependencies THEN running npm install to set up the project, but I agree with you @spacetyrant, the websites are completely unresponsive & broken

For anyone else whose tests are all passing but the website is still unresponsive, check out this thread here: https://discuss.codecademy.com/t/x-press-publishing-step-35-issue-with-app/499787/2

The base URL which the front-end Xpress.js file is using for fetch requests is ‘http://localhost:4000/api’, so setting the PORT to 4000 in server.js (mine was set at 4001) solved the issue, at least for me. Which is weird because the instructions specifically say we can choose any PORT number we like besides 8081 (although the hint underneath that step does say 4000.) But it wasn’t an issue of compatibility.

1 Like

Within the project files themselves, you can find a copy of the instructions. Within it does specify something about having to use port 4000, which I am sure I did not see on the web.

I lost many hours scratching my head before noticing it by chance. Another codecademy blunder.

Rather than downgrade node, try the following:

  • In a bash terminal, type npm outdated and enter to list deprecated packages
  • Then, type npx npm-check-updates -u and enter to update all packages
  • Finally, type npm install to complete the updates and update the package.json file
3 Likes

Thanks. This worked for me.

THANKS!!! It worked for me!

1 Like