anyenvのndenvで、vueコマンドが使えなかった
% mkdir example1 % cd example1 % cat .node-version v6.9.4
example1% npm install -g vue-cli インストール完了 example1% vue zsh: command not found: vue
コマンドが見つからない
example1% npm install -g @vue/cli インストール完了 example1% vue zsh: command not found: vue
コマンドが見つからない
PATHを通す
export PATH=$PATH:~/.anyenv/envs/ndenv/versions/v6.9.4/bin/ example1% vue You are using Node v6.9.4, but this version of vue-cli requires Node >=8.9. Please upgrade your Node version.
エラー
export PATH=$PATH:~/.anyenv/envs/ndenv/versions/v6.9.4/lib/node_modules/vue-cli/bin example1% vue Usage: vue <command> [options] Options: -V, --version output the version number -h, --help output usage information Commands: init generate a new project from a template list list available official templates build prototype a new project create (for v3 warning only) help [cmd] display help for [cmd]
動いた
vueプロジェクト作成
example1% vue init webpack app1-frontend-html ? Project name app1-frontend-html ? Project description A Vue.js project ? Author aaabbb <mail1@aaabbbbcccc.jp> ? Vue build standalone ? Install vue-router? No ? Use ESLint to lint your code? Yes ? Pick an ESLint preset Standard ? Set up unit tests Yes ? Pick a test runner jest ? Setup e2e tests with Nightwatch? Yes ? Should we run `npm install` for you after the project has been created? (recommended) npm vue-cli · Generated "app1-frontend-html". # Installing project dependencies ...
ローカルサーバー起動
example1% npm run dev npm ERR! Darwin 14.5.0 npm ERR! enoent ENOENT: no such file or directory, open '/Users/aaa/codes/vuejs/example1/package.json' npm ERR! enoent This is most likely not a problem with npm itself npm ERR! enoent and is related to npm not being able to find a file.
ローカルウェブサーバーが起動しなかった。
コマンドを実行する階層が違っていたのが原因だった。
example1/app1-frontend-html% npm run dev