yo angular生成错误路径(主目录)中的文件 [英] yo angular generates files in wrong path ( home directory )
问题描述
yo angular在我的主目录中生成文件,我不知道为什么.
yo angular generates the files in my home directory and I don't know why.
我做了以下事情:
节点的ppa
curl -sL https://deb.nodesource.com/setup | sudo bash -
然后安装节点
sudo apt-get install -y nodejs
创建符号链接
sudo ln -s "$(which nodejs)" /usr/bin/node
安装yeoman
sudo npm install -g yo
sudo npm install -g generator-angular
从 https://github.com/yeoman/generator-angular
mkdir my-new-project && cd $_
现在我跑步
yo angular test1
现在所有文件都将在我的主目录中创建,而不是在我当前所在的my-new-project目录中创建.我怎么了?
now all the files will be created in my home directory instead of the my-new-project directory where I am currently. What did I wrong?
节点-v:v0.10.36
node -v: v0.10.36
npm -v:2.5.1
npm -v: 2.5.1
Update1:新的npm版本
Update1: new npm version
解决方案:
yo angular在当前目录中查找.yo-rc.json文件,如果该文件不存在,它将尝试在主目录中找到它.要解决这个问题:
yo angular looks for .yo-rc.json file in the current directory, if the file isnt there it tries to find it in the home dir. To solve this:
在主目录中查找隐藏的.yo-rc.json文件并将其删除. 或在您要使用的目录中创建一个空的.yo-rc.json文件.
look for a hidden .yo-rc.json file in the home directory and delete it. Or create an empty .yo-rc.json file in the directory you want to use.
推荐答案
感谢在发布页面https://github.com/yeoman/generator-angular/issues/1037#issuecomment-83118093 解决方案相对简单.
Thanks to issue page at https://github.com/yeoman/generator-angular/issues/1037#issuecomment-83118093 the solutions was relatively easy.
在命令mkdir my-new-project && cd $_
之后
我需要使用{}
作为该文件夹的内容创建一个空的.yo-rc.json
文件.
After the command mkdir my-new-project && cd $_
I needed to create an empty .yo-rc.json
file with {}
as content to this folder.
然后我可以开始哟,所有文件现在都在my-new-project文件夹中创建.
Then I could start yo and all files are created in my my-new-project folder now.
这篇关于yo angular生成错误路径(主目录)中的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!