Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Power Apps Pro Dev & ISV
Unanswered

PCF - pcf-scripts - Cannot find module "Typescript"

(0) ShareShare
ReportReport
Posted on by 234

I went to create a new PCF project today, as a project has a requirement that I'd like to meet with a new component.

 

Receiving an error message when running pcf-scripts build.

 

 Executing task: npm run build <


> pcf-project@1.0.0 build C:\Users\NewcombR\source\repos\CSA\CSAPcf\PurchaseOrderAmountSummary
> pcf-scripts build

internal/modules/cjs/loader.js:905
 throw err;
 ^

Error: Cannot find module 'typescript'
Require stack:
- C:\Users\NewcombR\source\repos\CSA\CSAPcf\PurchaseOrderAmountSummary\node_modules\pcf-scripts\manifestTypesGenerator.js
- C:\Users\NewcombR\source\repos\CSA\CSAPcf\PurchaseOrderAmountSummary\node_modules\pcf-scripts\tasks\manifestTypesTask.js
- C:\Users\NewcombR\source\repos\CSA\CSAPcf\PurchaseOrderAmountSummary\node_modules\pcf-scripts\taskGroup.js
- C:\Users\NewcombR\source\repos\CSA\CSAPcf\PurchaseOrderAmountSummary\node_modules\pcf-scripts\bin\pcf-scripts.js 
 at Function.Module._resolveFilename (internal/modules/cjs/loader.js:902:15)
 at Function.Module._load (internal/modules/cjs/loader.js:746:27)
 at Module.require (internal/modules/cjs/loader.js:974:19)
 at require (internal/modules/cjs/helpers.js:92:18)
 at Object.<anonymous> (C:\Users\NewcombR\source\repos\CSA\CSAPcf\PurchaseOrderAmountSummary\node_modules\pcf-scripts\manifestTypesGenerator.js:6:12)
 at Module._compile (internal/modules/cjs/loader.js:1085:14)
 at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
 at Module.load (internal/modules/cjs/loader.js:950:32)
 at Function.Module._load (internal/modules/cjs/loader.js:790:14)
 at Module.require (internal/modules/cjs/loader.js:974:19) {
 code: 'MODULE_NOT_FOUND',
 requireStack: [
 'C:\\Users\\NewcombR\\source\\repos\\CSA\\CSAPcf\\PurchaseOrderAmountSummary\\node_modules\\pcf-scripts\\manifestTypesGenerator.js',
 'C:\\Users\\NewcombR\\source\\repos\\CSA\\CSAPcf\\PurchaseOrderAmountSummary\\node_modules\\pcf-scripts\\tasks\\manifestTypesTask.js',
 'C:\\Users\\NewcombR\\source\\repos\\CSA\\CSAPcf\\PurchaseOrderAmountSummary\\node_modules\\pcf-scripts\\taskGroup.js',
 'C:\\Users\\NewcombR\\source\\repos\\CSA\\CSAPcf\\PurchaseOrderAmountSummary\\node_modules\\pcf-scripts\\bin\\pcf-scripts.js'
 ]
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! pcf-project@1.0.0 build: `pcf-scripts build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the pcf-project@1.0.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\NewcombR\AppData\Roaming\npm-cache\_logs\2021-08-03T14_40_15_738Z-debug.log
The terminal process "C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe -Command npm run build" terminated with exit code: 1.

 

 

I created a second, PCF project and the results were the same.

 

I opened an existing PCF project and the build script worked as expected.

 

Is there I can "undo" the update that I installed this morning?  If not, what can I do to work through the issue?

  • Michael Mayo Profile Picture
    19 on at
    Re: PCF - pcf-scripts - Cannot find module "Typescript"

    You need to run "npm install --save-dev ajv@^7" from the project which will save into dev dependencies.

  • JvdSchelling Profile Picture
    18 on at
    Re: PCF - pcf-scripts - Cannot find module "Typescript"

    Hi DevidJen,

    This is the complete error log:

    [09:24:00] [build] Initializing...
    [09:24:00] [build] Validating manifest...
    [09:24:00] [build] Validating control...
    [09:24:02] [build] Running ESLint...
    [09:24:03] [build] Generating manifest types...
    [09:24:03] [build] Generating design types...
    [09:24:03] [build] Compiling and bundling control...
    [Webpack stats]:
    asset bundle.js 4.74 KiB [compared for emit] (name: main)
    ./PCFDemoCtrl/index.ts 39 bytes [not cacheable] [built] [code generated] [1 error]

    ERROR in ./PCFDemoCtrl/index.ts
    Module build failed (from ./node_modules/babel-loader/lib/index.js):
    Error: Cannot find module 'ajv/dist/compile/codegen'
    Require stack:
    - C:\Users\J.vanderSchelling\Downloads\PCF\controls\PCFDemo\node_modules\ajv-keywords\dist\definitions\typeof.js
    - C:\Users\J.vanderSchelling\Downloads\PCF\controls\PCFDemo\node_modules\ajv-keywords\dist\keywords\typeof.js
    - C:\Users\J.vanderSchelling\Downloads\PCF\controls\PCFDemo\node_modules\ajv-keywords\dist\keywords\index.js
    - C:\Users\J.vanderSchelling\Downloads\PCF\controls\PCFDemo\node_modules\ajv-keywords\dist\index.js
    - C:\Users\J.vanderSchelling\Downloads\PCF\controls\PCFDemo\node_modules\schema-utils\dist\validate.js
    - C:\Users\J.vanderSchelling\Downloads\PCF\controls\PCFDemo\node_modules\schema-utils\dist\index.js
    - C:\Users\J.vanderSchelling\Downloads\PCF\controls\PCFDemo\node_modules\babel-loader\lib\index.js
    - C:\Users\J.vanderSchelling\Downloads\PCF\controls\PCFDemo\node_modules\loader-runner\lib\loadLoader.js
    - C:\Users\J.vanderSchelling\Downloads\PCF\controls\PCFDemo\node_modules\loader-runner\lib\LoaderRunner.js
    - C:\Users\J.vanderSchelling\Downloads\PCF\controls\PCFDemo\node_modules\webpack\lib\NormalModule.js
    - C:\Users\J.vanderSchelling\Downloads\PCF\controls\PCFDemo\node_modules\webpack\lib\ModuleFilenameHelpers.js
    - C:\Users\J.vanderSchelling\Downloads\PCF\controls\PCFDemo\node_modules\esbuild-loader\dist\minify-plugin.js
    - C:\Users\J.vanderSchelling\Downloads\PCF\controls\PCFDemo\node_modules\esbuild-loader\dist\index.js
    - C:\Users\J.vanderSchelling\Downloads\PCF\controls\PCFDemo\node_modules\pcf-scripts\webpackConfig.js
    - C:\Users\J.vanderSchelling\Downloads\PCF\controls\PCFDemo\node_modules\pcf-scripts\tasks\compileTask.js
    - C:\Users\J.vanderSchelling\Downloads\PCF\controls\PCFDemo\node_modules\pcf-scripts\taskGroup.js
    - C:\Users\J.vanderSchelling\Downloads\PCF\controls\PCFDemo\node_modules\pcf-scripts\bin\pcf-scripts.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:902:15)
    at Function.Module._load (internal/modules/cjs/loader.js:746:27)
    at Module.require (internal/modules/cjs/loader.js:974:19)
    at Module.patchedRequire [as require] (C:\Users\J.vanderSchelling\Downloads\PCF\controls\PCFDemo\node_modules\diagnostic-channel\dist\src\patchRequire.js:16:46)
    at require (internal/modules/cjs/helpers.js:101:18)
    at Object.<anonymous> (C:\Users\J.vanderSchelling\Downloads\PCF\controls\PCFDemo\node_modules\ajv-keywords\dist\definitions\typeof.js:3:19)
    at Module._compile (internal/modules/cjs/loader.js:1085:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
    at Module.load (internal/modules/cjs/loader.js:950:32)
    at Function.Module._load (internal/modules/cjs/loader.js:790:12)

    webpack 5.75.0 compiled with 1 error in 416 ms
    [pcf-scripts] [Error] encountered unexpected error:
    Error: An error occurred compiling or bundling the control.
    npm ERR! code ELIFECYCLE
    npm ERR! errno 1
    npm ERR! pcf-project@1.0.0 build: `pcf-scripts build`
    npm ERR! Exit status 1
    npm ERR!
    npm ERR! Failed at the pcf-project@1.0.0 build script.
    npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

  • David Jenni Profile Picture
    Microsoft Employee on at
    Re: PCF - pcf-scripts - Cannot find module "Typescript"

    @JvdSchelling the error spew you pasted is missing all the other logging info, before the "webpack compiled with 1 error" message appears. Can you share the more complete log from the beginning, right after you entered `npm run build` ?

     

     

  • JvdSchelling Profile Picture
    18 on at
    Re: PCF - pcf-scripts - Cannot find module "Typescript"

    Hi,

    I have the same issue. Unfortunately none of the suggestions in this thread work 😞

    Error:

    webpack 5.75.0 compiled with 1 error in 410 ms
    [pcf-scripts] [Error] encountered unexpected error:
    Error: An error occurred compiling or bundling the control.
    npm ERR! code ELIFECYCLE
    npm ERR! errno 1
    npm ERR! pcf-project@1.0.0 build: `pcf-scripts build`
    npm ERR! Exit status 1
    npm ERR!
    npm ERR! Failed at the pcf-project@1.0.0 build script.
    npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

     

    This is quite frustrating. The information/ documentation is scarce and confusing. 

    So, this is my cry for help: Please help anyone!!

    Thanks!

     

  • Vishal Giri Profile Picture
    6 on at
    Re: PCF - pcf-scripts - Cannot find module "Typescript"

    Thanks for saving my day, it was very frustrating. As I was starting off with new control and was not able to build basic template itself.

  • David Jenni Profile Picture
    Microsoft Employee on at
    Re: PCF - pcf-scripts - Cannot find module "Typescript"

    we (the PCF/pac CLI tooling team) apologize for the breakage this caused: in the last 1.8.x release, we fixed a bug that typescript was mistakenly added as a runtime dependency: but TS is not a runtime dependency, e.g. TS should not get bundled etc.

     

    Having typescript installed globally (npm install -g typescript) would work on local dev machines, but likely not on build agents. That is the reason why this breakage went undetected locally within our team, sigh.

    But the idiomatic fix for npm/nodejs is to add typescript as a dev dependency in your package.json:
      

     

     

    npm install --save-dev typescript

     

     

    or if your project still needs TS 3
      

     

     

    npm install --save-dev typescript@^3

     

     

     

    The upcoming July refresh for PCF/pac CLI will contain updated package.json templates with TS already added as dev dependency

     

     

  • David Jenni Profile Picture
    Microsoft Employee on at
    Re: PCF - pcf-scripts - Cannot find module "Typescript"

    we (the PCF/pac CLI tooling team) apologize for the breakage this caused: in the last 1.8.x release, we fixed a bug that typescript was mistakenly added as a runtime dependency: but TS is not a runtime dependency, e.g. TS should not get bundled etc.

     

    Having typescript installed globally (npm install -g typescript) would work on local dev machines, but likely not on build agents. That is the reason why this breakage went undetected locally within our team, sigh.

    But the idiomatic fix for npm/nodejs is to add typescript as a dev dependency in your package.json:
      

     

    npm install --save-dev typescript

     

    or if your project still needs TS 3
      

     

    npm install --save-dev typescript@^3

     

     

    The upcoming July refresh for PCF/pac CLI will contain updated package.json templates with TS already added as dev dependency

     

     

  • Ryan S Newcomb Profile Picture
    234 on at
    Re: PCF - pcf-scripts - Cannot find module "Typescript"

    For what it’s worth, installing globally didn’t work.  (I already had it installed globally).

     

    Only by adding it as a local dependency

    worked.

  • Kristoffer88 Profile Picture
    87 on at
    Re: PCF - pcf-scripts - Cannot find module "Typescript"

    Hi.

     

    This has broken all our pipelines for our PCF apps, so we needed to add it to the package.json as a dev dependency on all our projects (after some lost hours debugging)

  • Hemant Gaur Profile Picture
    on at
    Re: PCF - pcf-scripts - Cannot find module "Typescript"

    Sorry for the break. I probed about this and here is the summary. There was a change in pcf-scripts module to move the typescript module to the devDependencies section which reduces bundle size. If your local nodejs doesn’t have typescript 3 or 4 installed globally, you’ll either need to do:

    • npm install --save-dev typescript
    • or: npm install -g typescript

    We’re updating the template in the July refresh

     

     

    thanks,

    Hemant 

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Congratulations to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Power Apps - Power Apps Pro Dev & ISV

#1
WarrenBelz Profile Picture

WarrenBelz 85 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 63 Super User 2025 Season 1

#3
mmbr1606 Profile Picture

mmbr1606 55 Super User 2025 Season 1

Overall leaderboard