web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / node_modules usage?
Power Apps
Answered

node_modules usage?

(0) ShareShare
ReportReport
Posted on by 12

tldr;

How do I import a specific JS file from an npm package?

 

I'm fairly new to this whole package deal but it feels hard to find a guide for my case, so I'd like to ask the pros here.

In my PCF I've been able to install and use jquery using 

npm install jquery
npm install @types/jquery

and

import $ from "jquery";

So I feel like I got the basics.

A component that I'd like to use now is summernote, a WYSIWYG editor:

https://summernote.org

There's a version that uses Bootstrap, and there's a version that doesn't. I'm trying to use the one that doesn't. So first step I installed the package using

npm install summernote

This created the summernote folder inside node_modules. And inside this summernote folder there are a couple files, one of them being the one for the version with BS (summernote.js) and one without (summernote-lite.js). Both create a new jquery extension called summernote and depending on which of these two JS files is being referenced it either uses the one with BS or the one without.

How do I tell my PCF which to use? While this statement compiles it obviously does not give the desired result:

import summernote from "summernote";

What exactly does this line import and from where (as in: from which file exactly)? How do I import specifically the summernote-lite.js from the package called summernote?

I have the same question (0)
  • Verified answer
    ScottDurow Profile Picture
    1,039 on at

    This is a fairly complex subject - but to use the code that you are importing, it must be written in such a way that supports modules.

    There is a good explanation here - https://javascript.info/modules-intro

    Additionally, the library must also provide typescript definitions - the most common source for theses are found at https://github.com/DefinitelyTyped/DefinitelyTyped - but equally the module itself might ship with d.ts files - or you can even write your own.

     

    When a library exports a module - it can then be packed (using webpack in the case of PCF) into the bundle.js. You might be used to using <SCRIPT> tags to use libraries - this would be an 'ambient' library and is not directly supported by PCF - that said you can inject <SCRIPT> definitions at runtime but I don't think it is technically supported to do that.

     

    Taking a quick look at summernote - it doesn't look like it supports javascript modules - and requires an ambient declaration using <SCRIPT> tags.

     

    I would suggest that you start by learning about javascript modules - then look at how you export and import - this will give you the necessary background to get to grips with how PCF uses external libraries when it bundles them using webpack.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 476

#2
WarrenBelz Profile Picture

WarrenBelz 365 Most Valuable Professional

#3
Vish WR Profile Picture

Vish WR 339

Last 30 days Overall leaderboard