Nodejs Kann Modul nicht finden
Beim Versuch, ein globales Modul zu verwenden, wird eine Fehlermeldung angezeigt. Beispiel:
Error: Cannot find module 'express'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:362:17)
at require (module.js:378:17)
at Object.<anonymous> (C:\BitNami\wappstack\...\test\app.js)
at Module._compile (module.js:449:26)
at Object.Module._extensions..js (module.js:467:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.runMain (module.js:492:10)
Ich habe den Expressbefehl installiert:
npm install -g express
Meine app.js:
var express = require('express');
Und führen Sie es mit Windows Powershell oder Node.js Eingabeaufforderungsfenster:
node app.js
weiß nicht wirklich was falsch läuft, ich lese etwas über Umgebungsvariablen in Windows, kann das sein?
Behoben / UpdateDas Problem war: Windows-Umgebungsvariablen wurden nicht für den Ordner npm konfiguriert. Suchen Sie nach Ihrem npm-Ordner und fügen Sie den Pfad in die Umgebungsvariablen ein.