{"content":"I was working on a new PCF control project and I encountered an unexpected error when attempting to build the project, even though no custom code had been added yet. (Cannot find module ajv/dist/compile/codegen)\nFor reference, I\u0026rsquo;m using the latest version ( at the time of writing) of the Microsoft Power Platform CLI ( 1.21.4+g4869036) and here are the steps to reproduce :\nExecute the init method of the pac cli. This will scaffold a new PCF control projects with all the basic dependencies. Execute npm install to download the dependencies Try to build the project : npm run build ❌Fails with error : Cannot find module \u0026ldquo;ajv/dist/compile/codegen\u0026rdquo; pac pcf init -ns \u0026lt;Namespace\u0026gt; -n \u0026lt;ProjectName\u0026gt; -t field npm install npm run build The error message is quite straitforward and points toward a node module that cannot be found : ajv/dist/compile/codegen . Upon checking the node_modules directory, even if the ajv module seems present, the compile/codegen part is nowhere to be found.\nI came across a similar issue ( yet unrelated to PCF control development) on Stack Overflow. Based on the accepted answer, I just added a reference to the ajv package in the dev dependencies of the PCF project.\nnpm install --save-dev ajv As you can see the missing module can now be found in the node_modules directory.\nAnd the project compiles flawlessly.\nHopefully this issue will be resolved quickly in future updates to the Microsoft Power Platform CLI. In the meantime, it is good to know that there is a workaround for it.\nHope this helps.\n","date":"2023-01-03T18:09:56Z","image":"/pcf-control-compile-error-cannot-find-module-ajv-dist-compile-codegen/error3.png","permalink":"/pcf-control-compile-error-cannot-find-module-ajv-dist-compile-codegen/","title":"PCF Control compile error : Cannot find module 'ajv/dist/compile/codegen'"}