J’ai une application Node JS très simple et j’aimerais inclure le framework Express JS . J’ai installé Express with NPM (et NPM avec Homebrew) sans erreur en utilisant:
brew install npm npm install express
Et mon fichier server.js
contient uniquement:
var express = require('express');
Lorsque j’exécute mon application, le message d’ Error: Cannot find module 'express'
. Comment puis-je dire à mon application Node d’inclure la bibliothèque?
Vous devez dire au noeud où sont vos bibliothèques.
extrait de http://nodejs.org/api.html
require.paths An array of search paths for require(). This array can be modified to add custom paths. Example: add a new path to the beginning of the search list require.paths.unshift('/usr/local/node');
Voici une procédure d’utilisation de la commande bundle de npm:
http://insortingdea.com/2010/8/24/using-npm-with-heroku-node-js?blog=company