[에러로그]
/Users/wise/study/nodejs/nodejs-textbook/learn-express/node_modules/serve-static/index.js:48
var opts = Object.create(options || null)
^
TypeError: Object prototype may only be an Object or null: /Users/wise/study/nodejs/nodejs-textbook/learn-express/public
at Function.create ()
at Function.serveStatic [as static] (/Users/wise/study/nodejs/nodejs-textbook/learn-express/node_modules/serve-static/index.js:48:21)
at Object. (/Users/wise/study/nodejs/nodejs-textbook/learn-express/app.js:21:32)
at Module._compile (node:internal/modules/cjs/loader:1254:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1308:10)
at Module.load (node:internal/modules/cjs/loader:1117:32)
at Module._load (node:internal/modules/cjs/loader:958:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
at node:internal/main/run_main_module:23:47
[해결]
p.249 예제처럼 express.static( path.join(__dirname, 'public'))로 수정하면 정상 작동하네요.
[도서 내 소스] app.use( morgan('dev'), express.static( '/', path.join(__dirname, 'public')), ... );
[에러로그] /Users/wise/study/nodejs/nodejs-textbook/learn-express/node_modules/serve-static/index.js:48 var opts = Object.create(options || null) ^ TypeError: Object prototype may only be an Object or null: /Users/wise/study/nodejs/nodejs-textbook/learn-express/public at Function.create ()
at Function.serveStatic [as static] (/Users/wise/study/nodejs/nodejs-textbook/learn-express/node_modules/serve-static/index.js:48:21)
at Object. (/Users/wise/study/nodejs/nodejs-textbook/learn-express/app.js:21:32)
at Module._compile (node:internal/modules/cjs/loader:1254:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1308:10)
at Module.load (node:internal/modules/cjs/loader:1117:32)
at Module._load (node:internal/modules/cjs/loader:958:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
at node:internal/main/run_main_module:23:47
[해결] p.249 예제처럼 express.static( path.join(__dirname, 'public'))로 수정하면 정상 작동하네요.