yo angular generates files in wrong path ( home di

2019-03-18 03:46发布

yo angular generates the files in my home directory and I don't know why.

I did the following:

ppa for node

curl -sL https://deb.nodesource.com/setup | sudo bash -

then install node

sudo apt-get install -y nodejs

create a symlink

sudo ln -s "$(which nodejs)" /usr/bin/node

install yeoman

sudo npm install -g yo
sudo npm install -g generator-angular

next steps from the instruction from https://github.com/yeoman/generator-angular

mkdir my-new-project && cd $_

now I run

yo angular test1

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?

node -v: v0.10.36

npm -v: 2.5.1

Update1: new npm version

Solution:

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:

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.

6条回答
对你真心纯属浪费
2楼-- · 2019-03-18 04:24

I searched for .yo-rc.json file in the folder it wrongfully creates your project in, then showed all hidden files via "defaults write com.apple.finder AppleShowAllFiles YES" in terminal then reload Finder ( alt button + right click on finder icon) and deleted the hidden .yo-rc.json file and other hidden files that came with it. Then reloaded finder again after using the same command as above but replace YES by NO. That did it for me !

查看更多
男人必须洒脱
3楼-- · 2019-03-18 04:28

This started happening to me after I ran yo from my home folder by mistake. Apparently I didn't clean up the generated files properly and left the ~/.yo-rc.json around. All you need to do is get rid of the .yo-rc.json in your home folder and run yo from your desired folder again.

查看更多
虎瘦雄心在
4楼-- · 2019-03-18 04:32

you should try not to install node with sudo, that causes your troubles. Take one instruction out of this link to install your node for usual user Instructions and it should work.

查看更多
叛逆
5楼-- · 2019-03-18 04:33

Probably you have there .yo-rc.json file. You should delete all hidden files in home directory which yeoman created and it's should works.

查看更多
祖国的老花朵
6楼-- · 2019-03-18 04:39

Thanks to issue page at https://github.com/yeoman/generator-angular/issues/1037#issuecomment-83118093 the solutions was relatively easy.

After the command mkdir my-new-project && cd $_ I needed to create an empty .yo-rc.json file with {} as content to this folder.

Then I could start yo and all files are created in my my-new-project folder now.

查看更多
男人必须洒脱
7楼-- · 2019-03-18 04:39

In case anyone else stumbles on this. The reason will be that a .yo-rc.json file is in the "wrong" directory.

Delete it and all will be well.

查看更多
登录 后发表回答