Heute habe ich seltsame Sache bekommen, dass, nachdem ich async in globalen installieren, Berichte NodeJS es nicht die module.following finden kann, ist der Workflownicht gefunden async nach der Installation
installieren async
npm installieren -g async
stellen Sie sicher, async existiert
npm Liste -g async
erhalten diese Ausgabe:
/usr/local/lib ├── [email protected] └─┬ [email protected] └─┬ [email protected] └─┬ [email protected] └── [email protected]
3.Try es zu benutzen.
I create a simple js file which only contains one statement: var async=require('async'); then execute the file via node, I get exception:
Error: Cannot find module 'async' at Function.Module._resolveFilename (module.js:338:15) at Function.Module._load (module.js:280:25) at Module.require (module.js:364:17) at require (module.js:380:17) at Object. (/lxzhu/nodejs/asynctest/test.js:1:73) at Module._compile (module.js:456:26) at Object.Module._extensions..js (module.js:474:10) at Module.load (module.js:356:32) at Function.Module._load (module.js:312:12) at Function.Module.runMain (module.js:497:10)
Warum installieren Sie es global?In der Regel sind die einzigen Dinge, die Sie global installieren, Pakete, bei denen Sie von einer ausführbaren Datei abhängig sind. –
Ich würde gerne wissen, warum auch - unabhängig von Best Practice. Ich würde annehmen, es würde funktionieren – cyberwombat