You can look up the latest version for any NPM package at. If you don’t know the exact version of the package, NPM allows using semantic ranges to define the version. This command will install the latest 4.x.x version. īoth aforementioned examples don’t modify package.json and don’t add installed modules to the list of dependencies. You can learn more about the syntax of semantic versioning at. Use -save to add the installed module to the package.json’s dependencies and -save-dev to add it to devDependencies. If you install a module without defining a specific version (i.e. without any version or using a semantic range), NPM will add the semantic range to the package.json as is. To prevent this, use -save-exact flag in addition to -save or -save-dev. This flag will force NPM to store the exact module version in the package.json. npm install lodash -save -save-exact - installs the latest version and saves the exact version in the dependencies in the package.json.npm install lodash -save-dev -save-exact - installs the latest version and saves the exact version in the devDependencies map in the package.json.
#NPM INSTALL LATEST VERSION OF PACKAGE HOW TO#
Learning Node.js? Get the book Node.Offline_boltQuick Start Introduction to Node.js A brief history of Node.js How to install Node.js How much JavaScript do you need to know to use Node.js? Differences between Node.js and the Browser