Skip to content
This repository has been archived by the owner on May 30, 2019. It is now read-only.

Node.js and npm Tips for Samplestack Development

Daphne Maddox edited this page Apr 24, 2015 · 3 revisions

Developers using Node.js and npm want and need stable installations of both Node.js and npm. This page is intended to help with issues concerning Node.js/npm usage, workarounds and versioning.

General Recommendation: Latest Stable Versions

As of the last time this document was updated, the most recent, stable versions are:

pkg version
node 0.10.33
npm 2.1.11

MarkLogic recommends that developers who can install specific versions use recent releases of both.

The rest of this document assumes that you have installed the latest versions or that you are unable or do not wish to do so.

Troubleshooting

If there are problems with:

  • running npm install; or
  • file-system errors when using gulp commands

then first, it is recommended to install the latest stable versions of node and npm.

If that is done (or not possible), and there is any history of errors on npm install, the npm troubleshooting wiki page should be consulted second.

Some specific workarounds that have been known to work include:

For Windows file-system errors (EPERM, ENOENT, and others)

If you receive EPERM, ENOENT or other Node.js-reported errors when it is trying to read/write/delete files during processing, disable real-time virus protection on the marklogic-samplestack directory.

For npm install

Sometimes a network or file- system "glitch" can, unfortunately wreak havoc on having the necessary dependencies installed.

On Windows, you can:

npm install -g rimraf # install a utility for deleting large directory trees

and then run these commands

rimraf node_modules
npm install

On Linux or Mac OS X, you can:

Run these commands

rm -rf node_modules
npm install

On any platform, the deletion of the node_modules directory followed by a re-attempt at npm install of the dependencies can help if you your machine is having trouble downloading files.

In some cases, you may end up with a corrupted installation of a particular dependency.

If your npm install command "mostly works", it may report an error with a specific dependency. In that happens, you can

rm -rf node_modules/<depname> # (or rimraf node_modules on windows)
npm install

to attempt to reinstall that specific package.

If you see the same errors on multiple attempts to npm install, you may try to clear your npm cache:

npm cache clean # (you may need 'sudo' on Linux/Mac)

For Gulp Errors

If you repeatedly see the same errors from gulp commands, please file an issue.

If you see intermittent errors, they may be reduced or eradicated by updating node/npm.

Using a Node Version Manager

Out of scope for this document but worth considering is to use a version manager for Node.js. This allows you to easily move been versions of node to find one that works for you. There are several available:

Feedback

In general, we love feedback of any kind. In particular, please share your experiences with us if you have trouble with node/npm so that we may improve our documentation. Thanks!