Search code examples
nestjsnomachine-nx

NX NestJs - Unexpected error: Error: Unable to load hasher for task "api:serve"


i have been trying to follow these guide to learn NX, but i encounter this problem when i tried to serve the nestJs api you can see the complete code on this repo

nx serve api

i get these error

Error: Unable to resolve @nrwl/node:execute.
Cannot find executor 'execute' in /Users/dariantvirgiesiswadie/Documents/pribadi/shirt-shop/node_modules/@nrwl/node/executors.json.
at Workspaces.readExecutor (/Users/dariantvirgiesiswadie/Documents/pribadi/shirt-shop/node_modules/@nrwl/tao/src/shared/workspace.js:92:19)
at getExecutorForTask (/Users/dariantvirgiesiswadie/Documents/pribadi/shirt-shop/node_modules/@nrwl/workspace/src/tasks-runner/utils.js:135:22)
at getCustomHasher (/Users/dariantvirgiesiswadie/Documents/pribadi/shirt-shop/node_modules/@nrwl/workspace/src/tasks-runner/utils.js:140:25)
at TasksSchedule.<anonymous> (/Users/dariantvirgiesiswadie/Documents/pribadi/shirt-shop/node_modules/@nrwl/workspace/src/tasks-runner/tasks-schedule.js:114:62)
at Generator.next (<anonymous>)
at /Users/dariantvirgiesiswadie/Documents/pribadi/shirt-shop/node_modules/tslib/tslib.js:117:75
at new Promise (<anonymous>)
at __awaiter (/Users/dariantvirgiesiswadie/Documents/pribadi/shirt-shop/node_modules/tslib/tslib.js:113:16)
at TasksSchedule.hashTask (/Users/dariantvirgiesiswadie/Documents/pribadi/shirt-shop/node_modules/@nrwl/workspace/src/tasks-runner/tasks-schedule.js:113:38)
at TasksSchedule.<anonymous> (/Users/dariantvirgiesiswadie/Documents/pribadi/shirt-shop/node_modules/@nrwl/workspace/src/tasks-runner/tasks-schedule.js:58:24)

Unexpected error:
Error: Unable to load hasher for task "api:serve"
at getCustomHasher (/Users/dariantvirgiesiswadie/Documents/pribadi/shirt-shop/node_modules/@nrwl/workspace/src/tasks-runner/utils.js:145:15)
at TasksSchedule.<anonymous> (/Users/dariantvirgiesiswadie/Documents/pribadi/shirt-shop/node_modules/@nrwl/workspace/src/tasks-runner/tasks-schedule.js:114:62)
at Generator.next (<anonymous>)
at /Users/dariantvirgiesiswadie/Documents/pribadi/shirt-shop/node_modules/tslib/tslib.js:117:75
at new Promise (<anonymous>)
at __awaiter (/Users/dariantvirgiesiswadie/Documents/pribadi/shirt-shop/node_modules/tslib/tslib.js:113:16)
at TasksSchedule.hashTask (/Users/dariantvirgiesiswadie/Documents/pribadi/shirt-shop/node_modules/@nrwl/workspace/src/tasks-runner/tasks-schedule.js:113:38)
at TasksSchedule.<anonymous> (/Users/dariantvirgiesiswadie/Documents/pribadi/shirt-shop/node_modules/@nrwl/workspace/src/tasks-runner/tasks-schedule.js:58:24)
at Generator.next (<anonymous>)
at /Users/dariantvirgiesiswadie/Documents/pribadi/shirt-shop/node_modules/tslib/tslib.js:117:75

i follow the guide literally 1 to 1, same name and everything. so i suppose the problem is with my local machine (?) i running macOS 12.2.1 with M1 chip. or maybe these guide using some old version of nx (?) and something changed on the mean time?

so if anyone can give me a clue on this, would be very appreciated. thanks

edit :

i've try to follow the official Nest with NX demo from their website. and still got the same error when i try to nx serve api


Solution

  • Ok, after some digging, it looks like some kind of a bug on the latest (4 March 2022) nx build. see this github issue on nrwl official repo.

    According to the comments there, To fix the issue just replace the following executers:

    "executor": "@nrwl/node:execute" -> "executor": "@nrwl/node:node"
    "executor": "@nrwl/node:build" -> "executor": "@nrwl/node:webpack"
    

    And that solve my problem too.