Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error on build #31

Closed
1 of 3 tasks
aloysius-tim opened this issue Apr 9, 2023 · 2 comments
Closed
1 of 3 tasks

Error on build #31

aloysius-tim opened this issue Apr 9, 2023 · 2 comments
Assignees
Labels
documentation Improvements or additions to documentation

Comments

@aloysius-tim
Copy link

Steps to reproduce

pnpm build && pnpm start

Expected behavior

Build succeed

Current behavior

Hi there,
Thank you for this great boilerplate ! Been working on it all day yesterday, but had a quack when I tried to build the project.

I tried building from the repo without any modification and had the same issue.

Looks like an issue with PINO. I tried many things to fix it and made it with on of the following:

  • Change these dependencies version to "nestjs-pino": "^2", "pino": "^6.4", "pino-http": "^5.6.0", "pino-pretty": "^6"
  • Or simply by added NODE_ENV=production to script.start in package.json

Any better way to fix it ?

Thanks,
Tim

pnpm build && pnpm start

> nestjs-v9-webpack-boilerplate@2.2.1 prebuild /Users/tim/Desktop/test
> rimraf dist


> nestjs-v9-webpack-boilerplate@2.2.1 build /Users/tim/Desktop/test
> nest build --webpack --webpackPath ./webpack.config.js

webpack 5.76.2 compiled successfully in 7767 ms

> nestjs-v9-webpack-boilerplate@2.2.1 start /Users/tim/Desktop/test
> node dist/main


node:internal/event_target:1010
  process.nextTick(() => { throw err; });
                           ^
Error: Cannot find module '/Users/tim/Desktop/test/dist/lib/worker.js'
    at Module._resolveFilename (node:internal/modules/cjs/loader:1075:15)
    at Module._load (node:internal/modules/cjs/loader:920:27)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
    at MessagePort.<anonymous> (node:internal/main/worker_thread:159:24)
    at [nodejs.internal.kHybridDispatch] (node:internal/event_target:735:20)
    at exports.emitMessage (node:internal/per_context/messageport:23:28)
Emitted 'error' event on Worker instance at:
    at [kOnErrorMessage] (node:internal/worker:290:10)
    at [kOnMessage] (node:internal/worker:301:37)
    at MessagePort.<anonymous> (node:internal/worker:202:57)
    at [nodejs.internal.kHybridDispatch] (node:internal/event_target:735:20)
    at exports.emitMessage (node:internal/per_context/messageport:23:28) {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}

Node.js v18.15.0
 ELIFECYCLE  Command failed with exit code 1.

Node.js version

18

In which operating systems have you tested?

  • macOS
  • Windows
  • Linux

Other

No response

@kenso312
Copy link
Owner

kenso312 commented Apr 10, 2023

Thanks for the report, it should be a known issue and the reason is because of pino-pretty. I do not point out that in the README is because I expect we will not use pino-pretty in a production build, so I assume you have NODE_ENV=production in the .env or docker env by default. But for some reason if you still want to use pino-pretty in the production, you can use pino-webpack-plugin to solve this, just simply install it and add some lines the webpack.config.js.

pnpm install -D pino-webpack-plugin
// webpack.config.js
const { PinoWebpackPlugin } = require('pino-webpack-plugin');

module.exports = {
  // ...
  plugins: [
    // ...
    new PinoWebpackPlugin({ transports: ['pino-pretty'] }),
  ],
}

I tested in the v2.2.1, seems upgraded packages make the webpack version not sync and break the build, so I have to force override the version to make it work. No this step requires for v2.2.0.

// package.json
{
  ...
  "pnpm": {
    "overrides": {
      "webpack": "^5.78.0"
    }
  }
}

Maybe I will point out this in the README for the next release, Thanks.

@kenso312 kenso312 added the documentation Improvements or additions to documentation label Apr 10, 2023
@kenso312 kenso312 self-assigned this Apr 10, 2023
@aloysius-tim
Copy link
Author

Works perfectly, thanks @kenso312 !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

2 participants