TypeError: Object # has no method ‘compile’ express node

This has bitten me twice now, so I’m just putting out there on the interwebs as a note to people searching for it.

When using Express with Node with a new project, you might get the error as:

Express server listening on port 3000 in development mode TypeError: Object # 

has no method 'compile' at Function.compile (/Users/iamwil/node_modules/express/lib/view.js:65:33) at ServerResponse._render (/Users/iamwil/node_modules/express/lib/view.js:416:18) at ServerResponse.render (/Users/iamwil/node_modules/express/lib/view.js:317:17) at Router. (/Users/iamwil/Dropbox/projects/scratch/hugalittle/app.js:23:16) at done (/Users/iamwil/node_modules/express/lib/router/index.js:250:22) at middleware (/Users/iamwil/node_modules/express/lib/router/index.js:244:9) at param (/Users/iamwil/node_modules/express/lib/router/index.js:227:11) at pass (/Users/iamwil/node_modules/express/lib/router/index.js:232:6) at Router._dispatch (/Users/iamwil/node_modules/express/lib/router/index.js:255:4) at Object.handle (/Users/iamwil/node_modules/express/lib/router/index.js:45:10)

This is because npm ‘freezes’ the package modules into your project, and you’ll need to do that every time you start a new project. All you need to do is install the dependencies:

npm install -d

in the root directory of your project. 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s