LoginSignup
4
2

More than 5 years have passed since last update.

Node.jsをアップデートしようとした際にnpm-cli.jsがエラー吐きまくる件

Posted at

きっかけはNginx+UnicornでRailsを動かそうとした時に
Unicorn周りではまってしまったので、一旦

rails -s

でサーバーを起動しようとした時のこと

webpackerがインストールされていないというエラーを吐き始めた。

Webpacker configuration file not found /xxx/Rails/yyy/config/webpacker.yml. 
Please run rails webpacker:install 
Error: No such file or directory @ rb_sysopen - 
/xxx/Rails/yyy/config/webpacker.yml (RuntimeError)

webpackerを入れようとすると、

$ bundle exec rails webpacker:install

Webpacker requires Node.js >= 6.14.4 and you are using 5.10.1
Please upgrade Node.js https://nodejs.org/en/download/

Nodeをアップデートするようにとのこと。

NPMをアップデートしようとすると、

$ npm update -g npm
/xxx/.nodebrew/node/v5.10.1/lib/node_modules/npm/bin/npm-cli.js:85
      let notifier = require('update-notifier')({pkg})
      ^^^

SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode
    at exports.runInThisContext (vm.js:53:16)
    at Module._compile (module.js:387:25)
    at Object.Module._extensions..js (module.js:422:10)
    at Module.load (module.js:357:32)
    at Function.Module._load (module.js:314:12)
    at Function.Module.runMain (module.js:447:10)
    at startup (node.js:146:18)
    at node.js:404:3

Nodeのバージョンが5.10.1と古く、letが使えないということなので、

https://qiita.com/gaikitan/items/406d6c4b1ccd1733318a
を参考にNodeを一度アンインストールしました。

$ which node
→ /usr/local/bin/node

rm -rf /usr/local/bin/node
// NPMも削除
rm -rf ~/.npm

そしてNodeをインストールし直しました。
(brewとnodebrewはもう入っていました)

$ brew -v
Homebrew 1.9.2
$ nodebrew -v
nodebrew 0.9.6
// バージョン確認
$ nodebrew ls-remote
$ nodebrew use v10.15.3
$ node -v
v10.15.3

$ rails s

して、localhostにアクセスすると無事RailsのHello Worldが表示されました。

4
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
2