我正在尝试构建msal,这样我就可以在nodejs中使用它。具体来说,我想验证测试用户在端到端的webdriverio测试中收到的电子邮件。
我遵循了npm指南这里并取得了相当大的进展,但在以下过程中出现了一些错误:
npm run build
。
npm run build
> msal@0.1.7 build C:\Users\User\TestAutomation\node_modules\msal
> npm run clean && npm run doc && npm run build:modules && webpack && grunt && npm test
> msal@0.1.7 clean C:\Users\User\TestAutomation\node_modules\msal
> shx rm -rf dist docs lib-commonjs lib-es6
> msal@0.1.7 doc C:\Users\User\TestAutomation\node_modules\msal
> typedoc --out ./docs ./src/**/* --gitRevision dev
Using TypeScript 2.2.2 from C:\Users\User\TestAutomation\node_modules\msal\node_modules\typedoc\node_modules\typescript\lib
Rendering [========================================] 100%
Documentation generated at C:\Users\User\TestAutomation\node_modules\msal\docs
> msal@0.1.7 build:modules C:\Users\User\TestAutomation\node_modules\msal
> tsc && tsc -m es6 --outDir lib-es6
Hash: 898d9837b77694c4a729
Version: webpack 3.12.0
Time: 244ms
Asset Size Chunks Chunk Names
msal.js 8.59 kB 0, 1 [emitted] msal
msal.min.js 3.26 kB 1, 0 [emitted] msal.min
msal.js.map 3.67 kB 0, 1 [emitted] msal
msal.min.js.map 14.4 kB 1, 0 [emitted] msal.min
[0] ./src/UserAgentApplication.ts 271 bytes {0} {1} [built] [failed] [1 error]
[1] ./src/Logger.ts 290 bytes {0} {1} [built] [failed] [1 error]
[2] multi ./src/index.ts 28 bytes {0} {1} [built]
[3] ./src/index.ts 354 bytes {0} {1} [built]
[4] ./src/User.ts 248 bytes {0} {1} [built] [failed] [1 error]
[5] ./src/Constants.ts 357 bytes {0} {1} [built] [failed] [1 error]
[6] ./src/RequestInfo.ts 247 bytes {0} {1} [built] [failed] [1 error]
[7] ./src/Authority.ts 209 bytes {0} {1} [built] [failed] [1 error]
ERROR in ./src/Logger.ts
Module parse failed: Unexpected token (26:7)
You may need an appropriate loader to handle this file type.
| import { Utils } from "./Utils";
|
| export interface ILoggerCallback {
| (level: LogLevel, message: string, containsPii: boolean): void;
| }
@ ./src/index.ts 2:0-34 3:0-36
@ multi ./src/index.ts
ERROR in ./src/Constants.ts
Module parse failed: Unexpected token (28:31)
You may need an appropriate loader to handle this file type.
| */
| export class Constants {
| static get errorDescription(): string { return "error_description"; }
| static get error(): string { return "error"; }
| static get scope(): string { return "scope"; }
@ ./src/index.ts 5:0-40
@ multi ./src/index.ts
ERROR in ./src/RequestInfo.ts
Module parse failed: Unexpected token (28:7)
You may need an appropriate loader to handle this file type.
| */
| export class TokenResponse {
| valid: boolean;
| parameters: Object;
| stateMatch: boolean;
@ ./src/index.ts 6:0-45
@ multi ./src/index.ts
ERROR in ./src/User.ts
Module parse failed: Unexpected token (30:17)
You may need an appropriate loader to handle this file type.
| export class User {
|
| displayableId: string;
| name: string;
| identityProvider: string;
@ ./src/index.ts 4:0-30
@ multi ./src/index.ts
ERROR in ./src/Authority.ts
Module parse failed: Unexpected token (34:7)
You may need an appropriate loader to handle this file type.
| * @hidden
| */
| export enum AuthorityType {
| Aad,
| Adfs,
@ ./src/index.ts 7:0-38
@ multi ./src/index.ts
ERROR in ./src/UserAgentApplication.ts
Module parse failed: Unexpected token (39:8)
You may need an appropriate loader to handle this file type.
| import { AuthorityFactory } from "./AuthorityFactory";
|
| declare global {
| interface Window {
| msal: Object;
@ ./src/index.ts 1:0-62 8:0-51
@ multi ./src/index.ts
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! msal@0.1.7 build: `npm run clean && npm run doc && npm run build:modules && webpack && grunt && npm test`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the msal@0.1.7 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:
我认为这是巴贝尔的错误:
You may need an appropriate loader to handle this file type
但我不知道如何解决这个问题。我也试过安装babel,不确定我是否需要它。
我对这些工具有点陌生,所以我确信这是一个简单的错误。我花了一点时间在这上面,所以我想伸出援手。如果我解决了,我会更新这个问题。
非常感谢MS团队提供msal。
更新:包括webpack.config.js
由webpack.config.js npm安装msal自动生成的
var path = require("path");
var webpack = require("webpack");
var PATHS = {
entryPoint: path.resolve(__dirname, 'src/index.ts'),
bundles: path.resolve(__dirname, 'dist'),
}
var config = {
entry: {
'msal': [PATHS.entryPoint],
'msal.min': [PATHS.entryPoint]
},
output: {
path: PATHS.bundles,
filename: '[name].js',
libraryTarget: 'umd',
library: 'Msal',
umdNamedDefine: true
},
resolve: {
extensions: ['.ts', '.tsx', '.js']
},
devtool: 'source-map',
plugins: [
new webpack.optimize.UglifyJsPlugin({
minimize: true,
sourceMap: true,
include: /\.min\.js$/,
})
],
module: {
loaders: [{
test: /\.tsx?$/,
loader: 'awesome-typescript-loader',
exclude: /node_modules/,
query: {
declaration: false,
}
}]
}
}
module.exports = config;
发布于 2018-07-24 11:19:11
You may need an appropriate loader to handle this file type
指的是特定文件类型缺少加载程序这一事实。
查看错误消息,它似乎在.ts文件上失败了。您是否可能忘记为类型记录文件添加一个类型记录文件加载器(T-装载机),而该文件似乎正在失败?
编辑
1)装载机使用的是loaders:
。我不知道这在任何意义上是否会影响到它,因为这种配置似乎仍然可以在Webpack 3中使用。(我不能在Webpack 4配置中使用loaders:
,因为编译时被加码标记为无效)。
所以我想弄清楚这是否产生了很大的影响,当我蹒跚而行的时候,我确实找到了MSAL 这里的类型记录样本。看起来他们在配置中也使用了规则。
module: {
rules: [
{
test: /\.tsx?$/,
loader: 'awesome-typescript-loader'
}
]
},
老实说,我不知道这会不会有什么区别。
https://stackoverflow.com/questions/51487574
复制相似问题