Error: Cannot find module 'node:path' when running Sanity dev

3 replies
Last updated: Jan 13, 2023
Hi,
I tried to init Sanity for my project, but i cant get the studio to start.
Never happend before.

i ran

npm create sanity@latest -- --template clean --create-project "musemPitten1000" --dataset production

installed just fine.
after

npm run dev

i get the following;

Error: Cannot find module 'node:path'

Require stack:

- C:/Users/Johannes/Desktop/Websites/pizSanity/node_modules/vite/dist/node-cjs/publicUtils.cjs

- C:/Users/Johannes/Desktop/Websites/pizSanity/node_modules/vite/index.cjs

- C:/Users/Johannes/Desktop/Websites/pizSanity/node_modules/sanity/lib/_chunks/devAction-c2147bc0.js

- C:/Users/Johannes/Desktop/Websites/pizSanity/node_modules/sanity/lib/_chunks/_internal-0ee4475e.js

- C:/Users/Johannes/Desktop/Websites/pizSanity/node_modules/sanity/lib/_internal.js

- C:/Users/Johannes/Desktop/Websites/pizSanity/node_modules/sanity/node_modules/@sanity/cli/lib/_chunks/getCliConfig-bf07f3b1.js

- C:/Users/Johannes/Desktop/Websites/pizSanity/node_modules/sanity/node_modules/@sanity/cli/lib/_chunks/cli-3c0c58fd.js

- C:/Users/Johannes/Desktop/Websites/pizSanity/node_modules/sanity/node_modules/@sanity/cli/lib/run.js

- C:/Users/Johannes/Desktop/Websites/pizSanity/node_modules/sanity/node_modules/@sanity/cli/bin/sanity

- C:/Users/Johannes/Desktop/Websites/pizSanity/node_modules/sanity/bin/sanity

at Object.<anonymous> (C:/Users/Johannes/Desktop/Websites/pizSanity/node_modules/vite/dist/node-cjs/publicUtils.cjs:3:14)

npm ERR! code ELIFECYCLE

npm ERR! errno 1
`npm ERR! musempitten1000@1.0.0 dev: `sanity dev``

npm ERR! Exit status 1

npm ERR!

npm ERR! Failed at the musempitten1000@1.0.0 dev script.

npm ERR! This is probably not a problem with npm. There is likely additional logging output above.


npm ERR! A complete log of this run can be found in:

npm ERR!     C:\Users\Johannes\AppData\Roaming\npm-cache\_logs\2023-01-12T13_22_09_880Z-debug.log

i tried npm install, sanity install, nothing worked.
please help!
AI Update

The error you're encountering (Cannot find module 'node:path') is a classic Node.js version compatibility issue. The node: protocol prefix for built-in modules requires a modern Node.js version, and based on your error, you're likely running an outdated version.

The Solution: Upgrade to Node.js 20 or higher

According to the Sanity Studio v4 requirements, you need Node.js version 20 or higher. When you ran npm create sanity@latest, you installed the latest Sanity Studio (v4), which requires this newer Node version.

Here's how to fix it:

  1. Check your current Node.js version:

    node -v
  2. Install Node.js 20 or higher:

    • Download from nodejs.org
    • Or use a version manager like nvm (recommended for managing multiple Node versions)

    If using nvm on Windows (nvm-windows):

    nvm install 20
    nvm use 20
  3. Verify the installation:

    node -v  # Should show v20.x.x or higher
  4. Delete node_modules and reinstall:

    cd C:/Users/Johannes/Desktop/Websites/pizSanity
    rmdir /s node_modules
    del package-lock.json
    npm install
  5. Start the dev server:

    npm run dev

The reason this requirement exists is that Node.js 18 reached end-of-life in April 2024, and Sanity Studio v4 needs the improvements from modern tooling like Vite 7, which requires Node 20+.

If you absolutely need to use an older Node version for other projects, consider using nvm to switch between Node versions per project. This way you can have different Node versions for different projects without conflicts.

Show original thread
3 replies
Thank you, but no solution there.Problem keeps appearing.

I never had this trouble with sanity before, now i cant setup a studio all of a sudden.
It works now.SOLUTION:
I updated node and npm to the latest versions and everything works fine now.

Sanity – Build the way you think, not the way your CMS thinks

Sanity is the developer-first content operating system that gives you complete control. Schema-as-code, GROQ queries, and real-time APIs mean no more workarounds or waiting for deployments. Free to start, scale as you grow.

Was this answer helpful?