1

I am trying to create a new Strapi app on Ubuntu 16.4 using MongoDB. After stepping through the tutorial, here: https://strapi.io/documentation/3.0.0-beta.x/guides/databases.html#mongodb-installation, I get the following error: Connection test failed: spawn npm; ENOENT

The error seems obvious, but I'm having issues getting to the cause of it. I've installed latest version of MongoDB and have ensured it is running using service mongod status. I can also connect directly using nc, like below.

$ nc -zvv localhost 27017
Connection to localhost 27017 port [tcp/*] succeeded!

Here is an image of the terminal output: enter image description here

Any help troubleshooting this would be appreciated! Does Strapi perhaps log setup errors somewhere, or is there a way to get verbose logging? Is it possible the connection error would be logged by MongoDB somewhere?

Paul
  • 337
  • 1
  • 3
  • 9

2 Answers2

0

I was able to find the answer. The problem was with using npx instead of Yarn. Strapi documentation states that either should work, however, it is clear from my experience that there is a bug when using npx.

I switched to Yarn and the process proceeded as expected without error. Steps were otherwise exactly the same.

Update: There is also a typo in Strapi documentation for yarn. They include the word "new" before the project name, which will create a project called new and ignore the project name.

Strapi docs (incorrect):

yarn create strapi-app new my-project

Correct usage, based on my experience:

yarn create strapi-app my-project
Paul
  • 337
  • 1
  • 3
  • 9
0

The ENOENT error is "an abbreviation of Error NO ENTry (or Error NO ENTity), and can actually be used for more than files/directories." Why does ENOENT mean "No such file or directory"?

Everything I've read on this points toward issues with environment variables and the process.env.PATH. "NOTE: This error is almost always caused because the command does not exist, because the working directory does not exist, or from a windows-only bug." How do I debug "Error: spawn ENOENT" on node.js?

If you take the function that Jiaji Zhou provides in the link above and paste it into the top of your config/functions/bootstrap.js file (above module.exports), it might give you a better idea of where the error is occurring, specifically it should tell you the command it ran. Then run the command > which nameOfCommand to see what file path it returns.
"miss-installed programs are the most common cause for a not found command. Refer to each command documentation if needed and install it." - laconbass (from the same link, below Jiaji Zhou's answer)

This is how I interpret all of the above and form a solution. Put that function in bootstrap.js, then take the command returned from the function and run > which nameOfCommand. Then in bootstrap.js (you can comment out the function), put console.log(process.env.PATH) which will return a string of all the directories your current environment is checking for executables. If the path returned from your which command isn't in your process.env.PATH, you can move the command into a path, or try re-installing.