인프런 커뮤니티 질문&답변

aoakua님의 프로필 이미지
aoakua

작성한 질문수

React로 NodeBird SNS 만들기

./node_modules/destroy/index.js Module not found: Can't resolve 'fs' 에러 확인 부탁드립니다 ~

작성

·

772

0

제로초님 안녕하세요~

 이 에러가 왜 나는 건지 알 수 있을까요? ㅠㅠ

검색해보니 webpack.config.js 설정을 해야한다고 하는데 강의에서 webpack.config.js 설정을 안했던 것 같아서요ㅜㅜ

도움 부탁드립니다!

[ event ] build page: /next/dist/pages/_error

[ wait ]  compiling ...

[ error ] ./node_modules/destroy/index.js

Module not found: Can't resolve 'fs' in 'D:\work\study\react-nodebird\front\node_modules\destroy'

{

  Component: [Function: Error] { displayName: 'ErrorPage' },

  router: ServerRouter {

    route: '/_error',

    pathname: '/_error',

    query: [Object: null prototype] {},

    asPath: '/favicon.ico'

  },

  ctx: {

    err: ModuleNotFoundError: Module not found: Error: Can't resolve 'fs' in 'D:\work\study\react-nodebird\front\node_modules\destroy'

        at D:\work\study\react-nodebird\front\node_modules\next\node_modules\webpack\lib\Compilation.js:823:10

        at D:\work\study\react-nodebird\front\node_modules\next\node_modules\webpack\lib\NormalModuleFactory.js:397:22

        at D:\work\study\react-nodebird\front\node_modules\next\node_modules\webpack\lib\NormalModuleFactory.js:130:21

        at D:\work\study\react-nodebird\front\node_modules\next\node_modules\webpack\lib\NormalModuleFactory.js:224:22

        at D:\work\study\react-nodebird\front\node_modules\neo-async\async.js:2830:7

        at D:\work\study\react-nodebird\front\node_modules\neo-async\async.js:6877:13

        at D:\work\study\react-nodebird\front\node_modules\next\node_modules\webpack\lib\NormalModuleFactory.js:214:25

        at D:\work\study\react-nodebird\front\node_modules\enhanced-resolve\lib\Resolver.js:213:14

        at D:\work\study\react-nodebird\front\node_modules\enhanced-resolve\lib\Resolver.js:285:5

        at eval (eval at create (D:\work\study\react-nodebird\front\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:13:1)

        at D:\work\study\react-nodebird\front\node_modules\enhanced-resolve\lib\UnsafeCachePlugin.js:44:7

        at D:\work\study\react-nodebird\front\node_modules\enhanced-resolve\lib\Resolver.js:285:5

        at eval (eval at create (D:\work\study\react-nodebird\front\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:13:1)

        at D:\work\study\react-nodebird\front\node_modules\enhanced-resolve\lib\Resolver.js:285:5

        at eval (eval at create (D:\work\study\react-nodebird\front\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:25:1)

        at D:\work\study\react-nodebird\front\node_modules\enhanced-resolve\lib\DescriptionFilePlugin.js:67:43 {

      details: "resolve 'fs' in 'D:\\work\\study\\react-nodebird\\front\\node_modules\\destroy'\n" +

        '  Parsed request is a module\n' +

        '  using description file: D:\\work\\study\\react-nodebird\\front\\node_modules\\destroy\\package.json (relative path: .)\n' +

        "    Field 'browser' doesn't contain a valid alias configuration\n" +

        '    resolve as module\n' +

        "      D:\\work\\study\\react-nodebird\\front\\node_modules\\destroy\\node_modules doesn't exist or is not a directory\n" +

        "      D:\\work\\study\\react-nodebird\\front\\node_modules\\node_modules doesn't exist or is not a directory\n" +

        "      D:\\work\\study\\react-nodebird\\node_modules doesn't exist or is not a directory\n" +

        "      D:\\work\\study\\node_modules doesn't exist or is not a directory\n" +

        "      D:\\work\\node_modules doesn't exist or is not a directory\n" +

        "      D:\\node_modules doesn't exist or is not a directory\n" +

        '      looking for modules in D:\\work\\study\\react-nodebird\\front\\node_modules\n' +

        '        using description file: D:\\work\\study\\react-nodebird\\front\\package.json (relative path: ./node_modules)\n' +

        "          Field 'browser' doesn't contain a valid alias configuration\n" +

        '          using description file: D:\\work\\study\\react-nodebird\\front\\package.json (relative path: ./node_modules/fs)\n' +

        '            no extension\n' +

        "              Field 'browser' doesn't contain a valid alias configuration\n" +

        "              D:\\work\\study\\react-nodebird\\front\\node_modules\\fs doesn't exist\n" +

        '            .mjs\n' +

        "              Field 'browser' doesn't contain a valid alias configuration\n" +

        "              D:\\work\\study\\react-nodebird\\front\\node_modules\\fs.mjs doesn't exist\n" +

        '            .js\n' +

        "              Field 'browser' doesn't contain a valid alias configuration\n" +

        "              D:\\work\\study\\react-nodebird\\front\\node_modules\\fs.js doesn't exist\n" +

        '            .jsx\n' +

        "              Field 'browser' doesn't contain a valid alias configuration\n" +

        "              D:\\work\\study\\react-nodebird\\front\\node_modules\\fs.jsx doesn't exist\n" +

        '            .json\n' +

        "              Field 'browser' doesn't contain a valid alias configuration\n" +

        "              D:\\work\\study\\react-nodebird\\front\\node_modules\\fs.json doesn't exist\n" +

        '            .wasm\n' +

        "              Field 'browser' doesn't contain a valid alias configuration\n" +

        "              D:\\work\\study\\react-nodebird\\front\\node_modules\\fs.wasm doesn't exist\n" +

        '            as directory\n' +

        "              D:\\work\\study\\react-nodebird\\front\\node_modules\\fs doesn't exist",

      missing: [Array],

      origin: [NormalModule],

      dependencies: [Array],

      module: [NormalModule],

      name: 'ModuleNotFoundError',

      error: [Error]

    },

    req: IncomingMessage {

      _readableState: [ReadableState],

      readable: true,

      _events: [Object: null prototype],

      _eventsCount: 1,

      _maxListeners: undefined,

      socket: [Socket],

      httpVersionMajor: 1,

      httpVersionMinor: 1,

      httpVersion: '1.1',

      complete: true,

      headers: [Object],

      rawHeaders: [Array],

      trailers: {},

      rawTrailers: [],

      aborted: false,

      upgrade: false,

      url: '/favicon.ico',

      method: 'GET',

      statusCode: null,

      statusMessage: null,

      client: [Socket],

      _consuming: false,

      _dumped: false,

      next: [Function: next],

      baseUrl: '',

      originalUrl: '/favicon.ico',

      _parsedUrl: [Url],

      params: [Object],

      query: {},

      res: [ServerResponse],

      _startAt: [Array],

      _startTime: 2020-03-29T05:58:57.514Z,

      _remoteAddress: '::1',

      body: {},

      secret: 'cookiesecret',

      cookies: [Object: null prototype] {},

      signedCookies: [Object: null prototype] {},

      _parsedOriginalUrl: [Url],

      sessionStore: [MemoryStore],

      sessionID: 'GXPl-ODhYWU_cMYjOCI1yXozByq-S-_U',

      session: [Session],

      route: [Route],

      [Symbol(kCapture)]: false

    },

    res: ServerResponse {

      _events: [Object: null prototype],

      _eventsCount: 2,

      _maxListeners: undefined,

      outputData: [],

      outputSize: 0,

      writable: true,

      _last: false,

      chunkedEncoding: false,

      shouldKeepAlive: true,

      useChunkedEncodingByDefault: true,

      sendDate: true,

      _removedConnection: false,

      _removedContLen: false,

      _removedTE: false,

      _contentLength: null,

      _hasBody: true,

      _trailer: '',

      finished: false,

      _headerSent: false,

      socket: [Socket],

      _header: null,

      _onPendingData: [Function: bound updateOutgoingData],

      _sent100: false,

      _expect_continue: false,

      req: [IncomingMessage],

      locals: [Object: null prototype] {},

      _startAt: undefined,

      _startTime: undefined,

      writeHead: [Function: writeHead],

      __onFinished: [Function],

      end: [Function: end],

      statusCode: 500,

      [Symbol(kCapture)]: false,

      [Symbol(kNeedDrain)]: false,

      [Symbol(corked)]: 0,

      [Symbol(kOutHeaders)]: [Object: null prototype]

    },

    pathname: '/_error',

    query: [Object: null prototype] {},

    asPath: '/favicon.ico',

    store: {

      dispatch: [Function (anonymous)],

      subscribe: [Function: subscribe],

      getState: [Function: getState],

      replaceReducer: [Function: replaceReducer],

      [Symbol(observable)]: [Function: observable]

    },

    isServer: true

  }

}

GET /favicon.ico 500 321.342 ms - 6475

[ event ] disposing inactive page(s): /, /next/dist/pages/_error

GET /_next/static/webpack/cf9ddfa83beeb19b28b8.hot-update.json 200 6.255 ms - 35

답변 8

1

제로초(조현영)님의 프로필 이미지
제로초(조현영)
지식공유자

destroy라는 모듈이 fs를 사용하고 있는데요. fs는 백엔드에서만 쓸수있는 모듈입니다. destroy도 따라서 백엔드에서만 쓸 수 있는 것으로 보입니다. 그런데 프론트에서 사용하고 계셔서 에러가 나는 것 같습니다.

0

aoakua님의 프로필 이미지
aoakua
질문자

감사합니다 제로초님~ 완강했어요!

0

제로초(조현영)님의 프로필 이미지
제로초(조현영)
지식공유자

지금 강좌가 next.config.js를 만드는 부분까지 진행되었는지 잘 모르겠습니다.

그 부분이 진행되었다면 next.config.js를 다음 링크처럼 수정하시면 됩니다.

https://github.com/zeit/next.js/issues/7755

0

aoakua님의 프로필 이미지
aoakua
질문자

이렇게 나옵니다!

0

제로초(조현영)님의 프로필 이미지
제로초(조현영)
지식공유자

npm ls destroy 하셔서 어떤 모듈이 destroy를 사용하는지 확인해보세요.

0

aoakua님의 프로필 이미지
aoakua
질문자

삭제하면 충돌난다고 나오네요 ㅠㅠ destory는 따로 사용한 적이 없는데 어떻게 해야할지 모르겠습니다 ㅠㅠ

0

제로초(조현영)님의 프로필 이미지
제로초(조현영)
지식공유자

네네 맞습니다. 비슷한 용도의 다른모듈 찾아보시는게 좋을 것 같습니다.

0

aoakua님의 프로필 이미지
aoakua
질문자

그럼 destroy를 프론트에서 삭제하면 되는건가요?

aoakua님의 프로필 이미지
aoakua

작성한 질문수

질문하기