我沿着以下代码实验室对约曼网页,到目前为止,我已经成功地跟着一起(有以下几个主要打嗝让我的开发环境中去,但现在它不返回任何错误).
所以我制作了我的项目文件夹并运行yo
,选择了AngularJS并运行该东西.很快进入这个过程我得到了一个提示,? Overwrite package.json?
我y
得到了以下警告:
npm WARN package.json codelab@0.0.0 No license field.
npm WARN peerDependencies The peer dependency karma@>=0.9 included from karma-jasmine will no
npm WARN peerDependencies longer be automatically installed to fulfill the peerDependency
npm WARN peerDependencies in npm 3+. Your application will need to depend on it explicitly.
npm WARN peerDependencies The peer dependency jasmine-core@* included from karma-jasmine will no
npm WARN peerDependencies longer be automatically installed to fulfill the peerDependency …
Run Code Online (Sandbox Code Playgroud) twitter-bootstrap angularjs yeoman bower yeoman-generator-angular
我正在开始学习使用AngularJS教程构建现代Web应用程序并尽早解决问题.
我安装了节点:
/path/ang-news node -v
v0.10.26
Run Code Online (Sandbox Code Playgroud)
我之前使用的是NPM但是遇到了Yeoman的问题.我已经重复了这些步骤,但是Grunt停止了工作,所以我开始新鲜了.
我跑了:
$ sudo npm install -g generator-angular
Run Code Online (Sandbox Code Playgroud)
并且所有依赖项都在安装,直到我收到:
npm WARN package.json mongo@0.1.0 No repository field.
npm ERR! peerinvalid The package generator-karma does not satisfy its siblings' peerDependencies requirements!
npm ERR! peerinvalid Peer generator-angular@0.9.1 wants generator-karma@>=0.8.2
Run Code Online (Sandbox Code Playgroud)
然后我尝试更新:
$ npm update -g
Run Code Online (Sandbox Code Playgroud)
我应该以管理员身份运行它.我收到了大量的错误消息,这似乎是最相关的:
npm ERR! Please try running this command again as root/Administrator.
npm ERR! System Darwin 13.1.0
npm ERR! command "/usr/local/bin/node" "/usr/local/bin/npm" "update" "-g"
npm ERR! cwd /path/ang-news
npm ERR! node -v …
Run Code Online (Sandbox Code Playgroud) yo angular在我的主目录中生成文件,我不知道为什么.
我做了以下事情:
节点的ppa
curl -sL https://deb.nodesource.com/setup | sudo bash -
Run Code Online (Sandbox Code Playgroud)
然后安装节点
sudo apt-get install -y nodejs
Run Code Online (Sandbox Code Playgroud)
创建符号链接
sudo ln -s "$(which nodejs)" /usr/bin/node
Run Code Online (Sandbox Code Playgroud)
安装自耕农
sudo npm install -g yo
sudo npm install -g generator-angular
Run Code Online (Sandbox Code Playgroud)
来自https://github.com/yeoman/generator-angular的说明的后续步骤
mkdir my-new-project && cd $_
Run Code Online (Sandbox Code Playgroud)
现在我跑了
yo angular test1
Run Code Online (Sandbox Code Playgroud)
现在所有文件都将在我的主目录中创建,而不是我当前所在的my-new-project目录.我错了什么?
node -v:v0.10.36
npm -v:2.5.1
Update1:新的npm版本
解:
yo angular在当前目录中查找.yo-rc.json文件,如果该文件不在那里它试图在home目录中找到它.要解决这个问题:
在主目录中查找隐藏的.yo-rc.json文件并将其删除.或者在要使用的目录中创建一个空的.yo-rc.json文件.
所以我想看看最新的发电机,看看他们现在使用gulp.
无论如何,在更新所有内容两次后,重新安装节点,删除npm-cache等等,当我做角度时,会发生以下情况:
然后它崩溃了(显然在运行npm install/bower install之前),并没有非常有用的消息
Error angular
You don't seem to have a generator with the name angular:common:C:\Users\myuser\AppData\Roaming\npm\node_modules\generator-angular\app\index.js installed.
Run Code Online (Sandbox Code Playgroud)
目录在那里(generator-angular).子目录在那里(generator-angular/common).index.js存在.我已经安装并更新了生成器和所有依赖项,如现在5次.
现在,奇怪的是,我尝试了旧版本的yo和生成器角度,它们都失败了同样的错误信息,所以它很可能是我的结果,但我无法弄明白.
我在StackOverflow上找到了这个问题的旧线程,但都通过更新或修复路径来解决.这些都没有帮助我:(
这是哟医生的输出
Yeoman Doctor
Running sanity checks on your system
? Global configuration file is valid
? Node.js version
? No .bowerrc file in home directory
? No .yo-rc.json file in home directory
? npm version
? NODE_PATH matches the npm root
Everything looks all right!
Run Code Online (Sandbox Code Playgroud)
我也在使用Win10x64.有任何想法吗?
使用'yo angular'我创建了AngularJS种子应用程序.
尝试使用'grunt serve'运行应用程序会出现此错误: -
>grunt serve
Loading "imagemin.js" tasks...ERROR
>> Error: Cannot find module 'imagemin-pngquant'
Running "serve" task
Running "clean:server" (clean) task
Running "wiredep:app" (wiredep) task
Warning: ENOENT, no such file or directory 'C:\a\b\c\yup\app\bower.json' Use --force to continue.
Aborted due to warnings.
Execution Time (2014-09-11 10:10:36 UTC)
loading tasks 10ms ??? 2%
wiredep:app 533ms ?????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? 97%
Total 549ms
Run Code Online (Sandbox Code Playgroud)
为什么它在app文件夹中寻找bower.json?它存在一级.
我怎样才能解决这个问题?
凉亭版 - 1.3.9
Grunt版本 - grunt v0.4.5
哟版本 - 1.2.1
Gruntfile.js: -
// Generated on 2014-09-11 using generator-angular 0.9.5 …
Run Code Online (Sandbox Code Playgroud) 我正在用角度发生器构建一个自耕农应用程序.
我的index.html文件中包含的js库是:
<script src="bower_components/jquery/dist/jquery.js"></script>
<script src="bower_components/modernizr/modernizr.js"></script>
<script src="bower_components/angular/angular.js"></script>
<script src="bower_components/angular-ui-router/release/angular-ui-router.js"></script>
<script src="bower_components/d3/d3.js"></script>
<script src="bower_components/select2/select2.js"></script>
<script src="bower_components/angular-ui-select2/src/select2.js"></script>
Run Code Online (Sandbox Code Playgroud)
只有在角度之前包含jquery时才会出现问题,如果它在它之后就不会发生.
标题所述的问题是我在控制台中得到"警告:尝试多次加载角度"并且应用程序无法初始化.
有没有人有任何线索为什么会发生这种情况?
我有一个ng-app,我只包括一次角度......以及一切.它看起来不像是与配置相关的东西,因为更改脚本的位置会修复它.
你们有什么线索吗?
有谁知道我是否能够配置包含脚本的顺序?当我使用角度生成器时,我已经使用usemin来设置它以包含bower脚本.我想知道是否有任何方法可以指定包含脚本的顺序.
这是我项目的bower.json文件:
{
"name": "<name>",
"version": "0.0.0",
"dependencies": {
"angular": "1.2.15",
"json3": "~3.2.6",
"es5-shim": "~2.1.0",
"angular-ui-router": "~0.2.10",
"modernizr": "~2.8.1",
"d3": "~3.4.6",
"angular-ui-select2": "~0.0.5"
},
"devDependencies": {
"angular-mocks": "1.2.15",
"angular-scenario": "1.2.15"
}
}
Run Code Online (Sandbox Code Playgroud)
我试图在谷歌搜索没有运气.提前致谢!
更新1:
我刚刚发现,如果我以这种方式包含脚本,则角度将不会包含两次,并且始终首先加载.
<!-- build:js scripts/vendor.js -->
<script src="bower_components/angular/angular.js"></script>
<!-- bower:js -->
<script src="bower_components/jquery/dist/jquery.js"></script>
<script src="bower_components/modernizr/modernizr.js"></script>
<script src="bower_components/angular-ui-router/release/angular-ui-router.js"></script>
<script src="bower_components/d3/d3.js"></script>
<script …
Run Code Online (Sandbox Code Playgroud) 我在自耕农中使用角度发生器.在gruntfile.js中,每个html文件都/app/views
被复制到dist/views
.但我喜欢将指令模板保存在与指令本身相同的文件夹中.
例:
/app/scripts/widgets/mywidget.directive.js
/app/scripts/widgets/mywidget.tmpl.html
Run Code Online (Sandbox Code Playgroud)
当我构建项目时,我希望html文件最终处于与上面相同的文件夹结构中.
这应该可以在gruntfile.js的copy部分中完成.
copy: {
dist: {
files: [{
expand: true,
dot: true,
cwd: '<%= yeoman.app %>',
dest: '<%= yeoman.dist %>',
src: [
'*.{ico,png,txt}',
'*.html',
'images/{,*/}*.{webp}',
'styles/fonts/{,*/}*.*'
]
}...
Run Code Online (Sandbox Code Playgroud)
我试着在src数组中添加它:
'<%= yeoman.dist %>/scripts/{,*/}*.tmpl.html'
Run Code Online (Sandbox Code Playgroud)
不工作.有任何想法吗?
我正在尝试设置你以使用角度生成器进行项目.我按照这里详细说明的步骤进行操作:http://yeoman.io/learning/index.html
我已经安装了Node.js和NPM.
但是当我使用命令时:
sudo npm install -g yo bower grunt-cli
Run Code Online (Sandbox Code Playgroud)
它失败了,我收到了这个错误:
> spawn-sync@1.0.11 postinstall /usr/lib/node_modules/yo/node_modules/cross-spawn/node_modules/spawn-sync
> node postinstall
fs.js:439
return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
^
Error: EACCES, permission denied '/usr/lib/node_modules/yo/node_modules/cross-spawn/node_modules/spawn-sync/package.json'
at Object.fs.openSync (fs.js:439:18)
at Object.fs.writeFileSync (fs.js:978:15)
at Object.<anonymous> (/usr/lib/node_modules/yo/node_modules/cross-spawn/node_modules/spawn-sync/postinstall.js:20:6)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:935:3
npm ERR! Linux 3.13.0-24-generic
npm ERR! argv "node" "/usr/bin/npm" "install" "-g" "yo"
npm ERR! node v0.10.37
npm ERR! npm v2.11.0
npm …
Run Code Online (Sandbox Code Playgroud) 我想知道是否有可能通过模块(如MEANJS生成器)将yeoman应用程序基本上与以下结构分开:
第3单元
App.js
对我来说这样做更方便,官方角度生成器不支持该结构
有没有办法用现有的自耕农发电机来实现这一目标?
我用yeoman角度生成器创建了一个AngularJS应用程序.现在我想使用Apache tomcat来托管它.
我已经运行了"grunt build"并且已经将所有资产准备好放在"dist"文件夹中了.有没有办法创建.war文件或者我可以将文件复制到tomcat中的文件夹吗?
angularjs ×7
yeoman ×7
bower ×3
gruntjs ×2
javascript ×1
node.js ×1
npm ×1
tomcat ×1
ubuntu-14.04 ×1
yo ×1