Nest: hor reaload - TypeError [ERR_INVALID_ARG_TYPE]: The "modulePath" argument must be of type string. Received undefined

Created on 17 Nov 2020  Â·  13Comments  Â·  Source: nestjs/nest

Bug Report

nest build --webpack --webpackPath webpack-hmr.config.js

 Info  Webpack is building your sources...

(node:11356) [DEP_WEBPACK_WATCH_WITHOUT_CALLBACK] DeprecationWarning: A 'callback' argument need to be provided to the 'webpack(options, callback)' function when the 'watch' option is set. There is no way to handle the 'watch' option without a callback.
(Use `node --trace-deprecation ...` to show where the warning was created)
(node:11356) UnhandledPromiseRejectionWarning: TypeError: undefined is not iterable (cannot read property Symbol(Symbol.iterator))
    at Function.from (<anonymous>)
    at Object.getChangedFiles (D:\nestJS\hot-reload\node_modules\fork-ts-checker-webpack-plugin\lib\hooks\getChangedFiles.js:11:17)
    at Object.<anonymous> (D:\nestJS\hot-reload\node_modules\fork-ts-checker-webpack-plugin\lib\hooks\tapStartToConnectAndRunReporter.js:49:49)
    at Generator.next (<anonymous>)
    at D:\nestJS\hot-reload\node_modules\fork-ts-checker-webpack-plugin\lib\hooks\tapStartToConnectAndRunReporter.js:8:71
    at new Promise (<anonymous>)
    at __awaiter (D:\nestJS\hot-reload\node_modules\fork-ts-checker-webpack-plugin\lib\hooks\tapStartToConnectAndRunReporter.js:4:12)
    at D:\nestJS\hot-reload\node_modules\fork-ts-checker-webpack-plugin\lib\hooks\tapStartToConnectAndRunReporter.js:41:83
    at Hook.eval [as call] (eval at create (D:\nestJS\hot-reload\node_modules\@nestjs\cli\node_modules\tapable\lib\HookCodeFactory.js:19:10), <anonymous>:100:1)
    at Hook.CALL_DELEGATE [as _call] (D:\nestJS\hot-reload\node_modules\@nestjs\cli\node_modules\tapable\lib\Hook.js:14:14)
(node:11356) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:11356) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
(node:11356) [DEP_WEBPACK_MODULE_ERRORS] DeprecationWarning: Module.errors was removed (use getErrors instead)
internal/validators.js:122
    throw new ERR_INVALID_ARG_TYPE(name, 'string', value);
    ^

TypeError [ERR_INVALID_ARG_TYPE]: The "modulePath" argument must be of type string. Received undefined
    at validateString (internal/validators.js:122:11)
    at fork (child_process.js:68:3)
    at createWorkerProcess (internal/cluster/master.js:132:10)
    at EventEmitter.cluster.fork (internal/cluster/master.js:167:25)
    at StartServerPlugin._startServer (D:\nestJS\hot-reload\node_modules\start-server-webpack-plugin\dist\StartServerPlugin.js:148:23)
    at StartServerPlugin.startServer (D:\nestJS\hot-reload\node_modules\start-server-webpack-plugin\dist\StartServerPlugin.js:124:10)
    at StartServerPlugin.afterEmit (D:\nestJS\hot-reload\node_modules\start-server-webpack-plugin\dist\StartServerPlugin.js:90:10)
    at Hook.eval [as callAsync] (eval at create (D:\nestJS\hot-reload\node_modules\@nestjs\cli\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:7:1)
    at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (D:\nestJS\hot-reload\node_modules\@nestjs\cli\node_modules\tapable\lib\Hook.js:18:14)
    at D:\nestJS\hot-reload\node_modules\@nestjs\cli\node_modules\webpack\lib\Compiler.js:754:27 {
  code: 'ERR_INVALID_ARG_TYPE'
}
**this is fresh, starter projekt, only test hot reload, but not working** ## Environment

    "@nestjs/common": "^7.0.0",
    "@nestjs/core": "^7.0.0",
    "@nestjs/platform-express": "^7.0.0",


    "@nestjs/cli": "^7.0.0",
    "@nestjs/schematics": "^7.0.0",
    "@nestjs/testing": "^7.0.0",
    "@types/express": "^4.17.3",
    "@types/jest": "26.0.10",
    "@types/node": "^13.9.1",
    "@types/supertest": "^2.0.8",
    "@typescript-eslint/eslint-plugin": "3.9.1",
    "@typescript-eslint/parser": "3.7.0",
    "eslint": "7.7.0",
    "eslint-config-prettier": "^6.10.0",
    "eslint-plugin-import": "^2.20.1",
    "jest": "26.4.2",
    "prettier": "^1.19.1",
    "start-server-webpack-plugin": "^2.2.5",
    "supertest": "^4.0.2",
    "ts-jest": "26.2.0",
    "ts-loader": "^6.2.1",
    "ts-node": "9.0.0",
    "tsconfig-paths": "^3.9.0",
    "typescript": "^3.7.4",
    "webpack": "^4.44.2",
    "webpack-node-externals": "^2.5.2"

image

needs triage

Most helpful comment

This is still related to the fact that @nestjs/cli^7.5.2 has webpack^5 as a dependency. If you install @nestjs/[email protected] the command works as expected. I wonder how feasible it would be to make typescript and webpack peerDependencies and what implications that would have.

All 13 comments

Duplicate of #5686 and #5667

Duplicate of #5686 and #5667

I do not agree. The hot-reload theme is common, but the error is not the same ...
and both are closed while an open bug, I don't see a solution in any of the posts. If it worked for me, it would be good with webpack@4 as well.

If you don't think it's the same, can you provide minimum reproduction?

Best regards,
Jay McDoniel

On Mon, Nov 16, 2020, 5:47 PM Kármán Zsombor notifications@github.com
wrote:

Duplicate of #5686 https://github.com/nestjs/nest/issues/5686 and #5667
https://github.com/nestjs/nest/issues/5667

I do not agree. The hot-reload theme is common, but the error is not the
same ...

—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/nestjs/nest/issues/5706#issuecomment-728632650, or
unsubscribe
https://github.com/notifications/unsubscribe-auth/AGXVRCD3P3VHQYGKH4IDCRLSQHI4LANCNFSM4TX5WMVQ
.

If you don't think it's the same, can you provide minimum reproduction? Best regards, Jay McDoniel
…
On Mon, Nov 16, 2020, 5:47 PM Kármán Zsombor @.*> wrote: Duplicate of #5686 <#5686> and #5667 <#5667> I do not agree. The hot-reload theme is common, but the error is not the same ... — You are receiving this because you commented. Reply to this email directly, view it on GitHub <#5706 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGXVRCD3P3VHQYGKH4IDCRLSQHI4LANCNFSM4TX5WMVQ .

Here is my source code:
https://github.com/Karman40/nestjs-hot-relod-bug

  1. nest new ...
  2. npm i --save-dev webpack-node-externals start-server-webpack-plugin
  3. npm i webpack@4 -D
  4. create webpack-hmr.config.js file with a docs content
  5. edit main.ts
  6. nest build --webpack --webpackPath webpack-hmr.config.js => than i get error

This is still related to the fact that @nestjs/cli^7.5.2 has webpack^5 as a dependency. If you install @nestjs/[email protected] the command works as expected. I wonder how feasible it would be to make typescript and webpack peerDependencies and what implications that would have.

start-server-webpack-plugin is incompatible with Webpack 5. Let's track this here https://github.com/ericclemmons/start-server-webpack-plugin/issues/40

That's fine. What made me think differently was that with a project I created a couple of weeks ago, everything went fine with these settings. packege.json was the same, but then it happened that there was a new release and in that project it didn't happen npm i.

Only nestjs 7.5> uses with webpack 5.
@Karman40 use "start-server-nestjs-webpack-plugin" in place of "start-server-webpack-plugin".
https://github.com/nestjs/docs.nestjs.com/pull/1545

start-server-nestjs-webpack-plugin

Thanks, I added, but I still have to use @ nestjs / cli "7.5.1" with webpack@4.
Why is this better than that?

for what its worth the documentation should be updated to match (and is not working for me just flipping to use start-server-nestjs-webpack-plugin)

https://docs.nestjs.com/recipes/hot-reload

Error List

Info  Webpack is building your sources...
api            | 
api            | (node:18) [DEP_WEBPACK_WATCH_WITHOUT_CALLBACK] DeprecationWarning: A 'callback' argument need to be provided to the 'webpack(options, callback)' function when the 'watch' option is set. There is no way to handle the 'watch' option without a callback.
api            | (Use `node --trace-deprecation ...` to show where the warning was created)
api            | (node:18) UnhandledPromiseRejectionWarning: TypeError: undefined is not iterable (cannot read property Symbol(Symbol.iterator))
api            |     at Function.from (<anonymous>)
api            |     at Object.getChangedFiles (/usr/src/node_modules/fork-ts-checker-webpack-plugin/lib/hooks/getChangedFiles.js:11:17)
api            |     at Object.<anonymous> (/usr/src/node_modules/fork-ts-checker-webpack-plugin/lib/hooks/tapStartToConnectAndRunReporter.js:49:49)
api            |     at Generator.next (<anonymous>)
api            |     at /usr/src/node_modules/fork-ts-checker-webpack-plugin/lib/hooks/tapStartToConnectAndRunReporter.js:8:71
api            |     at new Promise (<anonymous>)
api            |     at __awaiter (/usr/src/node_modules/fork-ts-checker-webpack-plugin/lib/hooks/tapStartToConnectAndRunReporter.js:4:12)
api            |     at /usr/src/node_modules/fork-ts-checker-webpack-plugin/lib/hooks/tapStartToConnectAndRunReporter.js:41:83
api            |     at Hook.eval [as call] (eval at create (/usr/src/node_modules/@nestjs/cli/node_modules/tapable/lib/HookCodeFactory.js:19:10), <anonymous>:100:1)
api            |     at Hook.CALL_DELEGATE [as _call] (/usr/src/node_modules/@nestjs/cli/node_modules/tapable/lib/Hook.js:14:14)
api            | (node:18) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
api            | (node:18) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
api            | (node:18) [DEP_WEBPACK_COMPILATION_ASSETS] DeprecationWarning: Compilation.assets will be frozen in future, all modifications are deprecated.
api            | BREAKING CHANGE: No more changes should happen to Compilation.assets after sealing the Compilation.
api            |        Do changes to assets earlier, e. g. in Compilation.hooks.processAssets.
api            |        Make sure to select an appropriate stage from Compilation.PROCESS_ASSETS_STAGE_*.
api            | ERROR in ../../node_modules/@nestjs/core/nest-application.js 17:120-173
api            | Module not found: Error: Can't resolve '@nestjs/microservices/microservices-module' in '/usr/src/node_modules/@nestjs/core'
api            |  @ ../../node_modules/@nestjs/core/index.js 25:21-50
api            |  @ ./src/main.ts 3:15-38
api            | 
api            | ERROR in ../../node_modules/@nestjs/mapped-types/dist/type-helpers.utils.js 59:29-65
api            | Module not found: Error: Can't resolve 'class-transformer/storage' in '/usr/src/node_modules/@nestjs/mapped-types/dist'
api            |  @ ../../node_modules/@nestjs/mapped-types/dist/index.js 18:27-58
api            |  @ ../../node_modules/@nestjs/mapped-types/index.js 6:9-26
api            |  @ ../../node_modules/@nestjs/swagger/dist/type-helpers/pick-type.helper.js 4:23-54
api            |  @ ../../node_modules/@nestjs/swagger/dist/type-helpers/index.js 16:13-42
api            |  @ ../../node_modules/@nestjs/swagger/dist/index.js 18:13-38
api            |  @ ../../node_modules/@nestjs/swagger/index.js 6:9-26
api            |  @ ./src/main.ts 4:18-44
api            | 
api            | ERROR in ../../node_modules/@nestjs/swagger/dist/swagger-module.js 45:106-132
api            | Module not found: Error: Can't resolve 'fastify-swagger' in '/usr/src/node_modules/@nestjs/swagger/dist'
api            |  @ ../../node_modules/@nestjs/swagger/dist/index.js 17:13-40
api            |  @ ../../node_modules/@nestjs/swagger/index.js 6:9-26
api            |  @ ./src/main.ts 4:18-44
api            | 
api            | ERROR in ../../node_modules/node-gyp/lib/Find-VisualStudio.cs 9:6
api            | Module parse failed: Unexpected token (9:6)
api            | You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
api            | | // This script needs to be compatible with PowerShell v2 to run on Windows 2008R2 and Windows 7.
api            | | 
api            | > using System;
api            | | using System.Text;
api            | | using System.Runtime.InteropServices;
api            |  @ ../../node_modules/node-gyp/lib/ sync ^\.\/.*$ ./Find-VisualStudio.cs
api            |  @ ../../node_modules/node-gyp/lib/node-gyp.js 41:13-36 190:36-53
api            |  @ ../../node_modules/node-pre-gyp/lib/util/compile.js 29:28-55
api            |  @ ../../node_modules/node-pre-gyp/lib/ sync ^\.\/.*$ ./util/compile.js ./util/compile
api            |  @ ../../node_modules/node-pre-gyp/lib/node-pre-gyp.js 52:13-36 184:38-55
api            |  @ ../../node_modules/bcrypt/bcrypt.js 3:13-36
api            |  @ ./src/auth/auth.service.ts 20:17-34
api            |  @ ./src/chat/chat.gateway.ts 19:23-54
api            |  @ ./src/app.module.ts 36:23-53
api            |  @ ./src/main.ts 5:21-44
api            | 
api            | ERROR in ../../node_modules/node-pre-gyp/lib/info.js 14:14-32
api            | Module not found: Error: Can't resolve 'aws-sdk' in '/usr/src/node_modules/node-pre-gyp/lib'
api            |  @ ../../node_modules/node-pre-gyp/lib/ sync ^\.\/.*$ ./info.js ./info
api            |  @ ../../node_modules/node-pre-gyp/lib/node-pre-gyp.js 52:13-36 184:38-55
api            |  @ ../../node_modules/bcrypt/bcrypt.js 3:13-36
api            |  @ ./src/auth/auth.service.ts 20:17-34
api            |  @ ./src/chat/chat.gateway.ts 19:23-54
api            |  @ ./src/app.module.ts 36:23-53
api            |  @ ./src/main.ts 5:21-44
api            | 
api            | ERROR in ../../node_modules/node-pre-gyp/lib/publish.js 18:14-32
api            | Module not found: Error: Can't resolve 'aws-sdk' in '/usr/src/node_modules/node-pre-gyp/lib'
api            |  @ ../../node_modules/node-pre-gyp/lib/ sync ^\.\/.*$ ./publish.js ./publish
api            |  @ ../../node_modules/node-pre-gyp/lib/node-pre-gyp.js 52:13-36 184:38-55
api            |  @ ../../node_modules/bcrypt/bcrypt.js 3:13-36
api            |  @ ./src/auth/auth.service.ts 20:17-34
api            |  @ ./src/chat/chat.gateway.ts 19:23-54
api            |  @ ./src/app.module.ts 36:23-53
api            |  @ ./src/main.ts 5:21-44
api            | 
api            | ERROR in ../../node_modules/node-pre-gyp/lib/unpublish.js 16:14-32
api            | Module not found: Error: Can't resolve 'aws-sdk' in '/usr/src/node_modules/node-pre-gyp/lib'
api            |  @ ../../node_modules/node-pre-gyp/lib/ sync ^\.\/.*$ ./unpublish.js ./unpublish
api            |  @ ../../node_modules/node-pre-gyp/lib/node-pre-gyp.js 52:13-36 184:38-55
api            |  @ ../../node_modules/bcrypt/bcrypt.js 3:13-36
api            |  @ ./src/auth/auth.service.ts 20:17-34
api            |  @ ./src/chat/chat.gateway.ts 19:23-54
api            |  @ ./src/app.module.ts 36:23-53
api            |  @ ./src/main.ts 5:21-44
api            | 
api            | ERROR in ../../node_modules/node-pre-gyp/lib/util/nw-pre-gyp/index.html 1:0
api            | Module parse failed: Unexpected token (1:0)
api            | You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
api            | > <!doctype html>
api            | | <html>
api            | | <head>
api            |  @ ../../node_modules/node-pre-gyp/lib/ sync ^\.\/.*$ ./util/nw-pre-gyp/index.html
api            |  @ ../../node_modules/node-pre-gyp/lib/node-pre-gyp.js 52:13-36 184:38-55
api            |  @ ../../node_modules/bcrypt/bcrypt.js 3:13-36
api            |  @ ./src/auth/auth.service.ts 20:17-34
api            |  @ ./src/chat/chat.gateway.ts 19:23-54
api            |  @ ./src/app.module.ts 36:23-53
api            |  @ ./src/main.ts 5:21-44
api            | 
api            | ERROR in ../../node_modules/pg/lib/native/client.js 4:13-33
api            | Module not found: Error: Can't resolve 'pg-native' in '/usr/src/node_modules/pg/lib/native'
api            |  @ ../../node_modules/pg/lib/native/index.js 2:0-36
api            |  @ ../../node_modules/pg/lib/index.js 27:26-45 38:24-43
api            |  @ ../../node_modules/typeorm/platform/PlatformTools.js 67:27-40
api            |  @ ../../node_modules/typeorm/entity-manager/MongoEntityManager.js 7:22-58
api            |  @ ../../node_modules/typeorm/index.js 119:27-73
api            |  @ ./src/messages/messages.service.ts 19:18-36
api            |  @ ./src/messages/messages.module.ts 14:27-56
api            |  @ ./src/app.module.ts 39:26-63
api            |  @ ./src/main.ts 5:21-44
api            | 
api            | webpack 5.4.0 compiled with 9 errors in 12838 ms
api            | (node:18) [DEP_WEBPACK_STATS_WARNINGS_FILTER] DeprecationWarning: config.stats.warningsFilter is deprecated in favor of config.ignoreWarnings
api            | /usr/src/node_modules/webpack/lib/WatchIgnorePlugin.js:26
api            |                const ignoredFiles = files.filter(ignored);
api            |                                           ^
api            | 
api            | TypeError: files.filter is not a function
api            |     at IgnoringWatchFileSystem.watch (/usr/src/node_modules/webpack/lib/WatchIgnorePlugin.js:26:30)
api            |     at Watching.watch (/usr/src/node_modules/@nestjs/cli/node_modules/webpack/lib/Watching.js:222:48)
api            |     at /usr/src/node_modules/@nestjs/cli/node_modules/webpack/lib/Watching.js:199:13
api            |     at processTicksAndRejections (internal/process/task_queues.js:75:11)

@Karman40 I had similar issue running start:dev. Installing @nestjs/cli dependency for my repo locally fixed it: yarn add -D @nestjs/[email protected].

@l3v1k Yes thanks for saying it before. In my writing above, I was puzzled as to what is better than a "start-server-webpack-plugin" because it doesn't work for me either? only 7.5.1 and webpack @ 4

Was this page helpful?
0 / 5 - 0 ratings