Note:

If you want to create a new page for developers, you should create it on the Moodle Developer Resource site.

NPM: Difference between revisions

From MoodleDocs
No edit summary
Line 6: Line 6:


=== npm shrinkwrap ===
=== npm shrinkwrap ===
We use [https://docs.npmjs.com/cli/shrinkwrap npm shrinkwrap] to ensure that all versions of packages are consistent for developers when they run `npm install`
We use [https://docs.npmjs.com/cli/shrinkwrap npm shrinkwrap] to ensure that all versions of packages are consistent for developers when they run <code bash>npm install</code>


=== Updating npm dependencies ===
=== Updating npm dependencies ===
Periodically we will update our npm dependencies, the process for doing this is:
Periodically we will update our npm dependencies, the process for doing this is:


# Run <code>$ npm outdated</code> to check for any outdated dependencies
# Run <code bash>$ npm outdated</code> to check for any outdated dependencies
# Examine each package change and judge whether the package should be updated
# Examine each package change and judge whether the package should be updated
# Update the package depdency version number in package.json
# Update the package depdency version number in package.json
# Update the package:  <code>$ npm update <packagename></code>
# Update the package:  <code bash>$ npm update <packagename></code>
# Update the shrinkwrap  (please note the --dev!): <code>$ npm shrinkwrap --dev</code>
# Update the shrinkwrap  (please note the --dev!): <code bash>$ npm shrinkwrap --dev</code>

Revision as of 17:40, 3 December 2015

Note: This page is a work-in-progress. Feedback and suggested improvements are welcome. Please join the discussion on moodle.org or use the page comments.

NPM is a package manager for JavaScript. It is used by Moodle developers to install a number of cli tools, primarily those related with Grunt.

npm dependency management

Tools installed by npm include things like our css/js compressors, post-processors and integrity checks. As differences in output from these tools would cause different results for different developers working on the same code, we need to ensure installed packages are the same.

npm shrinkwrap

We use npm shrinkwrap to ensure that all versions of packages are consistent for developers when they run npm install

Updating npm dependencies

Periodically we will update our npm dependencies, the process for doing this is:

  1. Run $ npm outdated to check for any outdated dependencies
  2. Examine each package change and judge whether the package should be updated
  3. Update the package depdency version number in package.json
  4. Update the package: $ npm update <packagename>
  5. Update the shrinkwrap (please note the --dev!): $ npm shrinkwrap --dev