Se scrivoGlobalmente set node_modules posizione per il progetto
var moment = require('moment');
nel mio progetto, i rifiuti Nodo un sacco di tempo a cercare in luoghi che in realtà non contengono il file, in quanto questo dtruss
spettacoli di uscita.
PID/THRD RELATIVE SYSCALL(args) = return
7079/0x7cf313: 1244530 stat64("/Users/burke/code/api/api/models/node_modules/moment\0", 0x7FFF5FBFE5D8, 0x9) = -1 Err#2
7079/0x7cf313: 1244575 stat64("/Users/burke/code/api/api/models/node_modules/moment.js\0", 0x7FFF5FBFE578, 0x9) = -1 Err#2
7079/0x7cf313: 1244595 stat64("/Users/burke/code/api/api/models/node_modules/moment.json\0", 0x7FFF5FBFE578, 0x9) = -1 Err#2
7079/0x7cf313: 1244612 stat64("/Users/burke/code/api/api/models/node_modules/moment.node\0", 0x7FFF5FBFE578, 0x9) = -1 Err#2
7079/0x7cf313: 1244628 stat64("/Users/burke/code/api/api/models/node_modules/moment.coffee\0", 0x7FFF5FBFE578, 0x9) = -1 Err#2
7079/0x7cf313: 1244663 open("/Users/burke/code/api/api/models/node_modules/moment/package.json\0", 0x0, 0x1B6) = -1 Err#2
7079/0x7cf313: 1244694 stat64("/Users/burke/code/api/api/models/node_modules/moment/index.js\0", 0x7FFF5FBFE578, 0x1B6) = -1 Err#2
7079/0x7cf313: 1244713 stat64("/Users/burke/code/api/api/models/node_modules/moment/index.json\0", 0x7FFF5FBFE578, 0x1B6) = -1 Err#2
7079/0x7cf313: 1244729 stat64("/Users/burke/code/api/api/models/node_modules/moment/index.node\0", 0x7FFF5FBFE578, 0x1B6) = -1 Err#2
7079/0x7cf313: 1244745 stat64("/Users/burke/code/api/api/models/node_modules/moment/index.coffee\0", 0x7FFF5FBFE578, 0x1B6) = -1 Err#2
7079/0x7cf313: 1244767 stat64("/Users/burke/code/api/api/node_modules/moment\0", 0x7FFF5FBFE5D8, 0x1B6) = -1 Err#2
7079/0x7cf313: 1244788 stat64("/Users/burke/code/api/api/node_modules/moment.js\0", 0x7FFF5FBFE578, 0x1B6) = -1 Err#2
7079/0x7cf313: 1244805 stat64("/Users/burke/code/api/api/node_modules/moment.json\0", 0x7FFF5FBFE578, 0x1B6) = -1 Err#2
7079/0x7cf313: 1244821 stat64("/Users/burke/code/api/api/node_modules/moment.node\0", 0x7FFF5FBFE578, 0x1B6) = -1 Err#2
7079/0x7cf313: 1244837 stat64("/Users/burke/code/api/api/node_modules/moment.coffee\0", 0x7FFF5FBFE578, 0x1B6) = -1 Err#2
7079/0x7cf313: 1244862 open("/Users/burke/code/api/api/node_modules/moment/package.json\0", 0x0, 0x1B6) = -1 Err#2
7079/0x7cf313: 1244887 stat64("/Users/burke/code/api/api/node_modules/moment/index.js\0", 0x7FFF5FBFE578, 0x1B6) = -1 Err#2
7079/0x7cf313: 1244904 stat64("/Users/burke/code/api/api/node_modules/moment/index.json\0", 0x7FFF5FBFE578, 0x1B6) = -1 Err#2
7079/0x7cf313: 1244920 stat64("/Users/burke/code/api/api/node_modules/moment/index.node\0", 0x7FFF5FBFE578, 0x1B6) = -1 Err#2
7079/0x7cf313: 1244936 stat64("/Users/burke/code/api/api/node_modules/moment/index.coffee\0", 0x7FFF5FBFE578, 0x1B6) = -1 Err#2
7079/0x7cf313: 1244964 stat64("/Users/burke/code/api/node_modules/moment\0", 0x7FFF5FBFE5D8, 0x1B6) = 0 0
7079/0x7cf313: 1244990 stat64("/Users/burke/code/api/node_modules/moment.js\0", 0x7FFF5FBFE578, 0x1B6) = -1 Err#2
7079/0x7cf313: 1245015 stat64("/Users/burke/code/api/node_modules/moment.json\0", 0x7FFF5FBFE578, 0x1B6) = -1 Err#2
7079/0x7cf313: 1245038 stat64("/Users/burke/code/api/node_modules/moment.node\0", 0x7FFF5FBFE578, 0x1B6) = -1 Err#2
7079/0x7cf313: 1245488 madvise(0x1008AE000, 0x21000, 0x9) = 0 0
7079/0x7cf313: 1245503 stat64("/Users/burke/code/api/node_modules/moment.coffee\0", 0x7FFF5FBFE578, 0x9) = -1 Err#2
7079/0x7cf313: 1245612 open("/Users/burke/code/api/node_modules/moment/package.json\0", 0x0, 0x1B6) = 11 0
C'è un modo per rendere il nodo non sprecare tanto tempo per cercare in posti che non contengono una directory node_modules
? Ad esempio, potrei impostare una specie di variabile di ambiente CHECK_HERE_FIRST=$HOME/code/api/node_modules
e se il requisito non è relativo a un percorso relativo, quello sarebbe il primo posto sul nodo controllato.
Potrei cambiare tutte le mie linee require
per caricare l'importazione relativa ma questo sembra complicato per un grande progetto.