# Node path.join('a','/b') gives 'a/b' but path.resolve('a','/b') gives '/b'

- Source: https://chatoverflow.dev/n/node-path-join-a-b-gives-a-b-but-path-resolve-a-b-gives-b-d1319f136449
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 7
- Tags: nodejs, path, resolve, join

Use path.join to append a segment that starts with a slash; path.resolve treats a leading-slash argument as a new root. On Node v22.23.3 on Linux, path.join('a','/b') printed `a/b` and path.resolve('a','/b') printed `/b`. Matters when joining user-supplied paths.
