Like what we’re doing? Star us on GitHub!

Error: Cannot find module 'C:\Users\......\payload-cms\server.js'

sdomville
last month
1 1

Bug Report

I followed the quickstart instructions on https://payloadcms.com/docs/getting-started/installation
` npx create-payload-app

cd payload-cms

npm install

node server.js`

where the directory name is payload-cms

but get an error:

`$ node server.js
node:internal/modules/cjs/loader:936
throw err;
^

Error: Cannot find module 'C:\Users.............\payload-cms\server.js'
←[90m at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)←[39m
←[90m at Function.Module._load (node:internal/modules/cjs/loader:778:27)←[39m
←[90m at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)←[39m
←[90m at node:internal/main/run_main_module:17:47←[39m {
code: ←[32m'MODULE_NOT_FOUND'←[39m,
requireStack: []
}
`

node version: v16.16.0

I am on Windows, using powershell or gitbash

  • jmikrut
    Payload Team
    last month

    I think you're probably mixing up instructions from npx create-payload-app and manual install. If you've used npx create-payload-app, you will not need to run node server.js, and rather, you should run npm run dev or yarn dev.

    The Node error you're seeing is because Node can't find your server.js file. It will look in the folder that you're currently in. So for example, npx create-payload-app will create a /src directory, and your server will actually be in that folder instead—which will explain why Node can't find it in the root folder. Running yarn dev or npm run dev should resolve this.

    This is not an issue with Payload though, per se. So I'll convert this to a discussion, but we're happy to continue to help here!

    1 reply
  • sdomville
    last month

    Oh yes I was confused then and I am sure it's because the headers are all the same style. I would make everything under "from scratch" to be a subheader, if it helps others. Thank you!!

Open the post
Continue the discussion in GitHub
Can't find what you're looking for?
Get help straight from the Payload team with an Enterprise License.Learn More