Angularjs 带鲍尔支架的网页包
我希望最好加载节点包,并且仅在不存在的情况下加载bower包 我只会使用Webpack站点中推荐的node包,但我需要加载一个位于bower中的库,然后 试一试 我安装了 但是当我运行Angularjs 带鲍尔支架的网页包,angularjs,bower,webpack,webpack-dev-server,Angularjs,Bower,Webpack,Webpack Dev Server,我希望最好加载节点包,并且仅在不存在的情况下加载bower包 我只会使用Webpack站点中推荐的node包,但我需要加载一个位于bower中的库,然后 试一试 我安装了 但是当我运行webpack dev server-d--watch时,错误会显示在chrome控制台中: Uncaught TypeError: angular.module is not a function(anonymous function) @ app.js:8__webpack_require__ @ bootst
webpack dev server-d--watch
时,错误会显示在chrome控制台中:
Uncaught TypeError: angular.module is not a function(anonymous function) @ app.js:8__webpack_require__ @ bootstrap 6cecf8d96fb5a1205f10:19(anonymous function) @ bootstrap 6cecf8d96fb5a1205f10:39__webpack_require__ @ bootstrap 6cecf8d96fb5a1205f10:19(anonymous function) @ bootstrap 6cecf8d96fb5a1205f10:39(anonymous function) @ bootstrap 6cecf8d96fb5a1205f10:39
angular.js:68Uncaught Error: [$injector:modulerr] Failed to instantiate module app due to:
Error: [$injector:nomod] Module 'app' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.
尝试使用ResolverPlugin(请参阅)
在webpack.config中,我添加了
plugins: [
...
, new webpack.ProvidePlugin({
Q: 'q',
store: 'store.js',
Stamplay: 'stamplay-js-sdk'
})
, new webpack.ResolverPlugin(
[
new webpack.ResolverPlugin.DirectoryDescriptionFilePlugin("bower.json", ["main"])
], ["normal", "loader"]
)
],
....
resolve: {
root: [
path.join(__dirname, 'node_modules'),
path.join(__dirname, 'bower_components')
],
但是,就像提到的Stamplay
对象是不正确的
尝试使用CDN和angular网页包插件
首先将脚本标记添加到index.html
其次,在webpack.config中添加外部
externals: {
stamplay: 'Stamplay'
},
最后<代码>新AngularPlugin进入webpack.config上的插件
这样,worsks但是我不能使用角度stamplay
,当我尝试时,模块stamplay
出现错误:(
见分支机构
完整的项目在这里:好的,从git尝试您的项目 正如我在会议上提到的,
无法解决模块“stamplay js sdk”
问题,然后在webpackBowerStarter目录中,我做了bower安装stamplay js sdk
,然后sudo npm运行构建
,瞧!完成了
在npm上运行start
,它与webpack dev server-d相同——观看
我喜欢
控制台说
sry如果你的意思是其他的。这能解决你的问题吗?Hi@aishwat,有些问题。即使在你的屏幕截图中,你也可以看到
Stamplay
对象中没有init
函数。在文档中,这个函数存在。即使你展开对象的详细信息,你也会看到这不是Stamplay对象。检查t如果我在index.html上做一个简单的
Stamplay.init(“APPID”);
在index.html上可以工作,但没有它就不行了。从Stamplay.js我可以得到函数(win){}
对象,因为它在全局/窗口范围函数('return this')()
。但是下一个函数(函数(root){})(this)
不会将init附加到Stamplay,因为它在之前的Stamplay.js中的这个上下文中;函数(win){
定义变量,然后设置变量,该变量=在内部存储;(函数(win){
然后在(函数(root){
putthat.init=root.Stamplay.init;
然后你得到Stamplay.init
工作。我不知道你想用init:DThanks做什么..我会试试。我只会使用Stamplay
对象作为:)而不仅仅是Stamplay.init(“APPID”)
但是Stamplay
对象的所有API..比如新的Stamplay.Cobject('dinner').Model;
@Ridermansb但是它不工作,所以接受了吗?你得到了一些修复吗?