简体   繁体   English

使用Signalr软件包构建项目时找不到模块

[英]Can not find modules while building the project with signalr package

I'm trying to use signalR in my react app. 我正在尝试在我的React应用中使用signalR。 When I'm importing it like this: 当我这样导入时:

import { HubConnection } from '@aspnet/signalr-client';

The build is going fine without uglify. 在没有丑陋的情况下构建正常。 But when I use uglify() it fails because of incompatibility of uglify and es6. 但是当我使用uglify()时,由于uglify和es6不兼容而失败。 I found the workaround : 我找到了解决方法

import { HubConnection } from '@aspnet/signalr-client/dist/browser/signalr-clientES5-1.0.0-alpha2-final.js';

but now when I'm trying to build the project, I'm getting errors like that: 但是现在当我尝试构建项目时,出现了这样的错误:

Cannot find module './HttpClient' from '...\node_modules\@aspnet\signalr-client\dist\browser'

These modules are located in 这些模块位于

'...\node_modules\@aspnet\signalr-client\dist\src\...'

So, how to fix the build in this case? 那么,在这种情况下如何修复构建?

The build task itself: 构建任务本身:

gulp.task('build', () => {
return browserify({
    entries: './wwwroot/js/client/app.jsx',
    extensions: ['.jsx'],
    debug: true
})
.transform('babelify', {
    presets: ['es2015', 'react'],
    plugins: ['transform-class-properties']
})
.bundle()
.on('error', function (err) {
    gutil.log(gutil.colors.red.bold('[browserify error]'));
    gutil.log(err.message);
    this.emit('end');
})
.pipe(source('app.bundle.js'))
.pipe(streamify(uglify().on('error', function(e){
    console.log(e);
 })))
.pipe(sourcemaps.write('./maps'))
.pipe(gulp.dest('wwwroot/dist/client'));
});

Thanks in advance! 提前致谢!

Use https://www.npmjs.com/package/@aspnet/signalr . 使用https://www.npmjs.com/package/@aspnet/signalr You're using a deprecated and unsupported package. 您正在使用不推荐使用且不受支持的软件包。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 为什么在构建项目时会出现问题? - Why is there a problem with building the project? 使用gulp构建durandaljs对于外部模块失败 - Building durandaljs with gulp fails for external modules 两个 SASS 项目可以共享同一个 node_modules 文件夹和 package,json 文件吗? - Can two SASS projects share the same node_modules folder and package,json file? Gulp Typescript任务找不到angular2模块,仍然可以正常编译 - Gulp typescript task can't find angular2 modules, compiles fine nonetheless Gulp:建筑打字稿项目正在创建权限问题 - Gulp: Building typescript project is creating permission issues 如何在yeoman项目中安装软件包? - how to install a package in yeoman project? 使用gulp编译打字稿找不到全局安装的打字稿包 - Using gulp to compile typescript can't find globally installed typescript package 使用Webpack构建资产时,请确保使用有效的软件包版本 - Ensure valid package version is used when building assets with webpack 使用节点软件包管理器,为什么会安装许多不需要的模块? - Using node package manager, why might it install many unwanted modules? npm start-为Foundation Emails项目加载模块的错误和失败 - npm start - errors and failure to load modules for Foundation Emails project
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM