16

I'm trying to follow this tutorial to learn about node.js:

http://cwbuecheler.com/web/tutorials/2014/restful-web-app-node-express-mongodb/

When I run "npm install" some of the messages I see include this:

npm WARN deprecated jade@1.11.0: Jade has been renamed to pug, please install the latest version of pug instead of jade
npm WARN deprecated transformers@2.1.0: Deprecated, use jstransformer

And then it goes ahead and seems to set up the application anyways. My package.json file currently looks like this:

{
  "name": "testapp",
  "version": "0.0.0",
  "private": true,
  "scripts": {
    "start": "node ./bin/www"
  },
  "dependencies": {
    "body-parser": "~1.13.2",
    "cookie-parser": "~1.3.5",
    "debug": "~2.2.0",
    "express": "~4.13.1",
    "jade": "~1.11.0",
    "morgan": "~1.6.1",
    "serve-favicon": "~2.3.0",
    "mongodb": "^1.4.4",
    "monk": "^1.0.1"
  }
}

Questions: (these questions apply to both packages that I got warned about, but for discussion purposes, I'm just going to pick on jade / pug)

If I wanted to change jade to pug, do i need to specify a version number in this package.json file? Or can I just tell it to get latest somehow? Also, do I need to blow away my folder structure and then rerun the npm install command? Or can I just edit the package.json file and retry npm install?

Lastly, based on your experience, how critical is it for me to change from jade to pug if i'm just trying to learn how node works? I'm tempted to just leave as is... but then again, if this app works, i know it's going to be rolled out into production.. so... i guess i should make the right decisions up front.

Thanks and sorry if my questions are really remedial.

Happydevdays
  • 1,982
  • 5
  • 31
  • 57

3 Answers3

28

looks like you have a few questions so I'll go through them in order. If you want to change jade to pug you can run the following from the command line:

npm uninstall jade --save

then

npm install pug --save 

unless you specify the version when installing by saying pug@1.1.0 for example you will get the current version. Here is the documentation for how you can specify versions in your JSON https://docs.npmjs.com/files/package.json but you can specify a specific version or a specify major or minor version. It really depends on what you want to do.

in order to remove modules that are not in your package.json file use the prune command:

npm prune

This should remove modules not listed in your json (as long as they aren't dependencies)

I believe Jade was forced to change their name in npm due to copyright issue. I think it would be a good idea to use the current name so you can stay up to date if there are changes to the package

nb:make sure to change the extension to .pug from .jade

SeanKelleyx
  • 1,155
  • 13
  • 15
7

If you use jade/pug files with Node.js/Express, change the template engine of your app to:

app.set('view engine', 'pug')

Also

npm install pug --save 

will install the latest version of pug@2.0.0-beta11 as of Mar 2017. This may require some changes in your old .jade files, for example you should simplify:

a(href="/#{link}")

to

a(href=link)

More about Breaking Changes #2305

Greg Herbowicz
  • 1,210
  • 1
  • 17
  • 18
2

For future references: Express authors now use express myapp --view=pug in their tutorial here. That way Pug is installed instead of deprecated Jade.

Alexandr Zarubkin
  • 899
  • 1
  • 11
  • 26