PBCopy Mac command

A couple of useful Mac terminal (or iTerm) commands are the PBCopy & PBPaste. Here is a demonstration of how they work.

There are two basic ways to copy using pbcopy:

$ pbcopy < source_file.txt
copies text in source_file.txt

$ pwd | pbcopy
copies the output from pwd (the current directory) to the Mac clipboard

The copied text can now be pasted (either using menu’s or the CMD + V keyboard shortcut) into other applications in the usual way.

PBPaste works using the same syntax but in reverse:

$ pbpaste > destination_file.txt
pastes the current Mac clipboard to destination_file.txt

$ cd `pbpaste`
change directory to what's is currently stored in Mac clipboard

npm start error – TypeError: Path must be a string. Received undefined

This is a common generic error received whilst attempting to run older typescript based projects still using the now deprecated TSD package manager, on a system using TSD’s replacement Typings.

tl;drĀ  I just want to get this thing running quickly:
Installing (the deprecated) TSD package manager is often fastest way to get around these backward compatability issues:

$ npm install tsd -g

[disclaimer]using deprecated software is bad, see below for real fixes![/disclaimer]


Ok, now let’s look at actually fixing the problem.Unfortunately, the error’s output can be rather ambiguous, generic and difficult to get much helpful info from:

$ npm start

> node start.js
ts-loader: Using typescript@1.8
webpack built [...hash] in 1ms

ERROR in ./src/index.tsx
Module build failed: TypeError: Path must be a string. Received undefined
at assertPath (path.js:7:11)
at Object.dirname (path.js:1324:5)
at ensureTypeScriptInstance (/[...project src dir]/index.js:156:103)
at Object.loader (/[...project src dir]/node_modules/ts-loader/index.js:375:14)
@ multi main


Suspecting the error may be due to the project having been created using TSD rather than Typings, with the project having a tsd.json file rather than a typings.json file.

TSD has now been deprecated in favor of Typings, but the quickest way to get the project running is to install TSD, however this is obviously not ideal for anything but quickly checking out a project.

The Typings website provides info on how to upgrade from TSD to Typings, here:

The official deprecation notice on the TSD GitHub page provides some more useful info and background too:

A potential confusion is that the tsconfig.json remains the same name (although some parameters may need altering, moved file references updated/deleted), now the tsd.json is called typings.json with a similar config, but potentially also in need of manual editing after running the basic Typing’s upgrade process.

But hopefully, running npm start should work:

$ npm start
Compiled successfully!

The app is running at:



If this does not work, a couple of additional steps may be required, including (but not limited to):

  • If a webpack compile errors say “Module build failed: Error: ENOENT: no such file or directory,” you should check your tsconfig.json file is not referencing any old tsd files which no longer exist (usually in the project’s typings/ directory).
  • You may need to create a tsconfig.json file in your project root directory (i.e. usually same one as package.json etc) if you do not already have one, visit the Typescript language homepage for more info. (Courtesy of https://www.garysieling.com/blog/fixing-webpack-error-path-must-string-received-undefined)
  • You may need to upgrade one or more old npm dependencies in your package.json file. Tools like npm-check-upgrades can help (use npm-check-upgrades -u to actually install the newer package versions – warning: may break the application).
  • Try suggestions from the above links, (e.g. the TSD deprecation announcement).
  • If all else fails, undo everything so far (if a git repo type:
    $ git checkout — .
    ) and install the TSD package manager (deprecated and bad, but a potential short-term workaround):
    $ npm install tsd -g


These package upgrade errors do seem to happen with a regular frequency, but are usually solvable with a bit of work. If the above solutions did not work for you or you have succeeded using another, please let others know about it in the coments.