0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

node.jsとnpmのバージョンを上げて失敗する方法。※2022年8月

Last updated at Posted at 2023-11-09

うまくいかなかった方法です。

古い情報を元に作業するとこうなるという見本です

※この内容は2022年8月に記録した内容です。

小規模サイトの開発環境として使用しているgulpでエラーが出ることが増えてきた。
node.jsはv.10で、古いのでアップデートしたい。

結果、nodeだけでなくnpmやモジュール類のアップデートも含めた面倒な作業となったので備忘として。

手順1 node.jsのアップデート

ノードのバージョンを調べる

$ node -v

homebrewをインストールしているとして、

$ nodebrew ls-remote

バージョンリストが並ぶ。

$ nodebrew install-binary v12.0.0  // インストールしたいバージョン
$ nodebrew use v12.0.0 // 使用するバージョンを指定

手順2 npmのバージョンアップ

$ nodebrew

package.jsonの中にある以下のモジュールを最新にする。

package.json
"dependencies": {
"connect-ssi": "^1.1.1",
"del": "^6.0.0",
"gulp-autoprefixer": "^8.0.0",
"gulp-connect": "^5.7.0",
"gulp-connect-php": "^1.0.3",
"gulp-imagemin": "^7.1.0",
"gulp-notify": "^4.0.0",
"gulp-plumber": "^1.2.1",
"gulp-sass": "^5.1.0",
"gulp-sourcemaps": "^3.0.0",
"gulp-uglify": "^3.0.2",
"imagemin-gifsicle": "^7.0.0",
"imagemin-mozjpeg": "^9.0.0",
"imagemin-pngquant": "^9.0.2",
"sass": "^1.54.5"
},
"devDependencies": {
"browser-sync": "^2.27.10",
"gulp": "^4.0.2",
"gulp-watch": "^5.0.1",
"util.promisify": "^1.1.1"
}

結果

gulpfile.jsでrequireを使用しているのは古い書き方。これがエラーとなってしまう。
これからはimportで書くことになる。

0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?