Ich verwechsle über relative URL in Express js. Ich habe 2 file: app.js und config.js ich in "my_app" -Ordner bin (Anwendungsordner), und führen App:express js - require ('config.js')
In app.js:
var config = require('config.js');
// => throw err : Cannot find module 'config.js'
var config = require('/config.js');
// => throw err : Cannot find module '/config.js'
var config = require('./config.js');
// => throw err : Cannot find module 'http://localhost:3000/config.js'
var config = require(__dirname + '/config.js');
// => throw err : Cannot find module 'http://localhost:3000/config.js'
Wo ist my_app Ordner? Es befindet sich nicht im Befehl "require", obwohl es im Inneren beginnt.
Dies ist meine Struktur:
start
-- controllers
-- models
-- node_modules
-- public
-- views
app.js
config.js
package.json
router.js
Bitte geben Sie mir geht! Vielen Dank!
Haben Sie einen Ordner node_modules? –
Sicher habe ich. –
Können Sie versuchen, es dort zu finden? –