[英]Angular-new-router not found with browserify
I am setting up an angular project with browserify. 我正在使用browserify设置一个角度项目。
I have a gulp task that take all vendor modules from bower_components
directory and put them in a bundle: 我有一个bower_components
任务,它从bower_components
目录中获取所有供应商模块,并将它们放在捆绑中:
gulp.task('dependencies', function () {
return browserify({
entries: [dependencies.js],
})
.transform(debowerify)
.bundle()
.pipe(source(config.filenames.release.dep))
//.pipe(streamify(uglify()))
.pipe(gulpif(release,
gulp.dest(config.paths.dest.release.scripts),
gulp.dest(config.paths.dest.build.scripts)));
The dependencies.js
file contains this code: dependencies.js
文件包含以下代码:
'use strict';
// bower dependencies (can be edited in package.json)
var angular = require('angular');
require('angular-ui-router');
Everything works fine. 一切正常。 Now I try to change the ui-router
with angular-new-router
. 现在,我尝试用angular-new-router
更改ui-router
angular-new-router
。
My new dependencies.js
(My gulp task doesn't change): 我的新dependencies.js
(我一饮而尽任务不会改变):
'use strict';
// bower dependencies (can be edited in package.json)
var angular = require('angular');
require('angular-new-router');
And for information here's my bower.json
file: 有关信息,这是我的bower.json
文件:
{
"name": "test",
"private": true,
"dependencies": {
"angular": "~1.4.x",
"angular-new-router": "*",
"angular-ui-router": "*"
}
}
With this new config browserify return a weird error: 有了这个新的配置,browserify返回一个奇怪的错误:
: Cannot find module './....\\bower_components\\angular-new-router\\angular-new-router.js' from 'D:\\Devs\\sharefun\\WebApplication2\\src\\WebApplication2\\client\\modules' at D:\\Devs\\sharefun\\WebApplication2\\src\\WebApplication2\\node_modules\\browserify\\node_modules\\resolve\\lib\\async.js:55:21 at load (D:\\Devs\\sharefun\\WebApplication2\\src\\WebApplication2\\node_modules\\browserify\\node_modules\\resolve\\lib\\async.js:69:43) at onex (D:\\Devs\\sharefun\\WebApplication2\\src\\WebApplication2\\node_modules\\browserify\\node_modules\\resolve\\lib\\async.js:92:31) at D:\\Devs\\sharefun\\WebApplication2\\src\\WebApplication2\\node_modules\\browserify\\node_modules\\resolve\\lib\\async.js:22:47 at Object.oncomplete (fs.js:107:15) :在D的'D:\\ Devs \\ sharefun \\ WebApplication2 \\ src \\ WebApplication2 \\ client \\ modules'中找不到模块'./....\\bower_components\\angular-new-router\\angular-new-router.js' \\ Devs \\ sharefun \\ WebApplication2 \\ src \\ WebApplication2 \\ node_modules \\ browserify \\ node_modules \\ resolve \\ lib \\ async.js:55:21加载时(D:\\ Devs \\ sharefun \\ WebApplication2 \\ src \\ WebApplication2 \\ node_modules \\ browserify \\ node_modules \\在D:\\处的onex(D:\\ Devs \\ sharefun \\ WebApplication2 \\ src \\ WebApplication2 \\ node_modules \\ browserify \\ node_modules \\ resolve \\ lib \\ async.js:92:31)下的resolve \\ lib \\ async.js:69:43) Devs \\ sharefun \\ WebApplication2 \\ src \\ WebApplication2 \\ node_modules \\ browserify \\ node_modules \\ resolve \\ lib \\ async.js:22:47 at Object.oncomplete(fs.js:107:15)
What I find weird is that browserify is looking for bower_components\\angular-new-router\\angular-new-router.js
instead of bower_components\\angular-new-router\\index.js
我觉得很奇怪的是,浏览器正在寻找bower_components\\angular-new-router\\angular-new-router.js
而不是bower_components\\angular-new-router\\index.js
you kind of have the answer, specify full path to index.js. 如果您有答案,请指定index.js的完整路径。 try 尝试
require(angular-new-router/index.js);
or 要么
import 'angular-new-router/index.js';
for ES6 对于ES6
to anyone who is having this problem now it might be useful to know that new router package is not updated anymore but you can get it from angular project. 对于现在遇到此问题的任何人,了解新的路由器软件包不再更新,但您可以从有角度的项目中获取它可能很有用。 the latest example working with angular 1.5, components() and child routes can be found here: http://plnkr.co/edit/N3YP3dKMuljpZ6mWsVBT?p=preview 可在以下位置找到使用angular 1.5,components()和子路径的最新示例: http : //plnkr.co/edit/N3YP3dKMuljpZ6mWsVBT?p=preview
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.