admin管理员组文章数量:1317742
I am trying to integrate ADAL JS sample code:
.js
into a sharepoint framework client webpart:
my code is very simple, I already installed with NPM, adal, fs, node-fs, etc.
However I see this error
./~/adal-node/lib/util.js
Module not found: Error: Cannot resolve module 'fs' in /Users/luis.valencia/Documents/GraphSamples/Sample1/node_modules/adal-node/lib
resolve module fs in /Users/luis.valencia/Documents/GraphSamples/Sample1/node_modules/adal-node/lib
looking for modules in /Users/luis.valencia/Documents/GraphSamples/Sample1/node_modules/adal-node/lib
/Users/luis.valencia/Documents/GraphSamples/Sample1/node_modules/adal-node/lib/fs doesn't exist (module as directory)
resolve 'file' fs in /Users/luis.valencia/Documents/GraphSamples/Sample1/node_modules/adal-node/lib
resolve file
and the code I have is this:
I even mented the require JS line, but it looks like adal js library itself uses FS which doesnt seem to be correctly installed?
import {
BaseClientSideWebPart,
IPropertyPaneSettings,
IWebPartContext,
PropertyPaneTextField
} from '@microsoft/sp-client-preview';
import styles from './Hellomsgraph.module.scss';
import * as strings from 'hellomsgraphStrings';
import { IHellomsgraphWebPartProps } from './IHellomsgraphWebPartProps';
import * as MicrosoftGraph from "microsoft-graph"
const accessToken:string = "";
//var fs = require('fs');
var adal = require('adal-node');
var AuthenticationContext = adal.AuthenticationContext;
export default class HellomsgraphWebPart extends BaseClientSideWebPart<IHellomsgraphWebPartProps> {
public constructor(context: IWebPartContext) {
super(context);
}
public render(): void {
this.domElement.innerHTML = `
<div class="${styles.hellomsgraph}">
<div class="${styles.container}">
<div class="ms-Grid-row ms-bgColor-themeDark ms-fontColor-white ${styles.row}">
<div class="ms-Grid-col ms-u-lg10 ms-u-xl8 ms-u-xlPush2 ms-u-lgPush1">
<span class="ms-font-xl ms-fontColor-white">Wele to SharePoint!</span>
<p class="ms-font-l ms-fontColor-white">Customize SharePoint experiences using Web Parts.</p>
<p class="ms-font-l ms-fontColor-white">${this.properties.description}</p>
<a href="" class="ms-Button ${styles.button}">
<span class="ms-Button-label">Learn more</span>
</a>
</div>
</div>
</div>
</div>`;
}
protected get propertyPaneSettings(): IPropertyPaneSettings {
return {
pages: [
{
header: {
description: strings.PropertyPaneDescription
},
groups: [
{
groupName: strings.BasicGroupName,
groupFields: [
PropertyPaneTextField('description', {
label: strings.DescriptionFieldLabel
})
]
}
]
}
]
};
}
}
I am trying to integrate ADAL JS sample code:
https://github./AzureAD/azure-activedirectory-library-for-nodejs/blob/master/sample/client-credentials-sample.js
into a sharepoint framework client webpart:
my code is very simple, I already installed with NPM, adal, fs, node-fs, etc.
However I see this error
./~/adal-node/lib/util.js
Module not found: Error: Cannot resolve module 'fs' in /Users/luis.valencia/Documents/GraphSamples/Sample1/node_modules/adal-node/lib
resolve module fs in /Users/luis.valencia/Documents/GraphSamples/Sample1/node_modules/adal-node/lib
looking for modules in /Users/luis.valencia/Documents/GraphSamples/Sample1/node_modules/adal-node/lib
/Users/luis.valencia/Documents/GraphSamples/Sample1/node_modules/adal-node/lib/fs doesn't exist (module as directory)
resolve 'file' fs in /Users/luis.valencia/Documents/GraphSamples/Sample1/node_modules/adal-node/lib
resolve file
and the code I have is this:
I even mented the require JS line, but it looks like adal js library itself uses FS which doesnt seem to be correctly installed?
import {
BaseClientSideWebPart,
IPropertyPaneSettings,
IWebPartContext,
PropertyPaneTextField
} from '@microsoft/sp-client-preview';
import styles from './Hellomsgraph.module.scss';
import * as strings from 'hellomsgraphStrings';
import { IHellomsgraphWebPartProps } from './IHellomsgraphWebPartProps';
import * as MicrosoftGraph from "microsoft-graph"
const accessToken:string = "";
//var fs = require('fs');
var adal = require('adal-node');
var AuthenticationContext = adal.AuthenticationContext;
export default class HellomsgraphWebPart extends BaseClientSideWebPart<IHellomsgraphWebPartProps> {
public constructor(context: IWebPartContext) {
super(context);
}
public render(): void {
this.domElement.innerHTML = `
<div class="${styles.hellomsgraph}">
<div class="${styles.container}">
<div class="ms-Grid-row ms-bgColor-themeDark ms-fontColor-white ${styles.row}">
<div class="ms-Grid-col ms-u-lg10 ms-u-xl8 ms-u-xlPush2 ms-u-lgPush1">
<span class="ms-font-xl ms-fontColor-white">Wele to SharePoint!</span>
<p class="ms-font-l ms-fontColor-white">Customize SharePoint experiences using Web Parts.</p>
<p class="ms-font-l ms-fontColor-white">${this.properties.description}</p>
<a href="https://github./SharePoint/sp-dev-docs/wiki" class="ms-Button ${styles.button}">
<span class="ms-Button-label">Learn more</span>
</a>
</div>
</div>
</div>
</div>`;
}
protected get propertyPaneSettings(): IPropertyPaneSettings {
return {
pages: [
{
header: {
description: strings.PropertyPaneDescription
},
groups: [
{
groupName: strings.BasicGroupName,
groupFields: [
PropertyPaneTextField('description', {
label: strings.DescriptionFieldLabel
})
]
}
]
}
]
};
}
}
Share
Improve this question
edited Jan 31, 2017 at 21:48
Shawn Tabrizi
12.4k2 gold badges42 silver badges73 bronze badges
asked Nov 11, 2016 at 4:18
Luis ValenciaLuis Valencia
34k99 gold badges309 silver badges532 bronze badges
4
- Are you using webpack? – Matt Browne Commented Nov 11, 2016 at 4:22
- stackoverflow./questions/37506714/… – Matt Browne Commented Nov 11, 2016 at 4:23
- Yes SharepointFramework uses webpack, I read the other link but couldnt see a solution – Luis Valencia Commented Nov 11, 2016 at 4:40
-
fs
is a builtin module in node, no need to install it. – arboreal84 Commented May 9, 2017 at 5:10
1 Answer
Reset to default 7add this to webpack.config.js
target: 'node',
See here and here
本文标签: javascriptModule not found Error Cannot resolve module 39fs39 inStack Overflow
版权声明:本文标题:javascript - Module not found: Error: Cannot resolve module 'fs' in - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742020566a2414522.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论