20211127のNode.jsに関する記事は4件です。

nodeのバージョンを切り替えても反映されない問題の対処法

firebaseのサーバを立ち上げる時のnodeバージョンに合わせるために、node12からnode14にバージョンアップしたのに、なぜかfirebaseの方で何故か反映されていない事態が発生。 ↓エラー内容 やってた事 $ nodebrew install 14.18.1 $ nodebrew use 14.18.1 して $ node -v $ 14.18.1 なのに firebaseのサーバを起動しようとすると、 こっちはnodeのバージョンが14なのにあなたは12ですと怒られてしまう... 対処法 nodeとfirebaseのpathを確認してみる $ which node $ /Users/higu/.nodebrew/current/bin/node $ which node $ /usr/local/bin/firebase どうやらfirebaseのpathが原因っぽい? →/usr/local/bin/firebaseは実行可能ファイルの実際の場所ではない なんだろうこのファイルは...このファイルは消そう! $ cd / $ rm -rf /usr/local/bin/firebase もう一回pathを確認 $ which firebase $ /Users/higu/.nodebrew/current/bin/firebase そこそこ!! $ readlink $(which firebase) しておく必要もあるみたいです これで無事firebaseのサーバ立ち上げに成功しました! pathが原因のエラーが出てしまうと詰まりがちです;; 一応ここら辺に関係しそうなパスを紹介しておきます [.zshrc] ↓このパスを通さないとnode -vで14.16.0になってしまうので export PATH="/usr/local/bin/node/14.16.0/bin/:$PATH" export PATH=$HOME/.nodebrew/current/bin:$PATH こちらを参考にしました
  • このエントリーをはてなブックマークに追加
  • Qiitaで続きを読む

vue serve しようと思ったら digital envelope routines::unsupported が出た

はじめに エラーメッセージ Error: error:0308010C:digital envelope routines::unsupported at new Hash (node:internal/crypto/hash:67:19) at Object.createHash (node:crypto:130:10) at module.exports (/Users/~~~~~~~/.nvm/versions/node/v17.1.0/lib/node_modules/@vue/cli-service-global/node_modules/webpack/lib/util/createHash.js:135:53) at NormalModule._initBuildHash (/Users/~~~~~~~/.nvm/versions/node/v17.1.0/lib/node_modules/@vue/cli-service-global/node_modules/webpack/lib/NormalModule.js:417:16) at handleParseError (/Users/~~~~~~~/.nvm/versions/node/v17.1.0/lib/node_modules/@vue/cli-service-global/node_modules/webpack/lib/NormalModule.js:471:10) at /Users/~~~~~~~/.nvm/versions/node/v17.1.0/lib/node_modules/@vue/cli-service-global/node_modules/webpack/lib/NormalModule.js:503:5 at /Users/~~~~~~~/.nvm/versions/node/v17.1.0/lib/node_modules/@vue/cli-service-global/node_modules/webpack/lib/NormalModule.js:358:12 at /Users/~~~~~~~/.nvm/versions/node/v17.1.0/lib/node_modules/@vue/cli-service-global/node_modules/loader-runner/lib/LoaderRunner.js:373:3 at iterateNormalLoaders (/Users/~~~~~~~/.nvm/versions/node/v17.1.0/lib/node_modules/@vue/cli-service-global/node_modules/loader-runner/lib/LoaderRunner.js:214:10) at Array.<anonymous> (/Users/~~~~~~~/.nvm/versions/node/v17.1.0/lib/node_modules/@vue/cli-service-global/node_modules/loader-runner/lib/LoaderRunner.js:205:4) at Storage.finished (/Users/~~~~~~~/.nvm/versions/node/v17.1.0/lib/node_modules/@vue/cli-service-global/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:55:16) at /Users/~~~~~~~/.nvm/versions/node/v17.1.0/lib/node_modules/@vue/cli-service-global/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:91:9 at /Users/~~~~~~~/.nvm/versions/node/v17.1.0/lib/node_modules/@vue/cli-service-global/node_modules/graceful-fs/graceful-fs.js:123:16 at FSReqCallback.readFileAfterClose [as oncomplete] (node:internal/fs/read_file_context:68:3) { opensslErrorStack: [ 'error:03000086:digital envelope routines::initialization error' ], library: 'digital envelope routines', reason: 'unsupported', code: 'ERR_OSSL_EVP_UNSUPPORTED' } Node.js v17.1.0 調査 Node を v17.0.1 にアップデートし、cliでプロジェクトを作って、vue serveをしたら出てきてしまうらしい。 https://github.com/vuejs/vue-cli/issues/6770 https://github.com/webpack/webpack/issues/14532 OpenSSLのバージョンが3.0になったことに起因している問題みたいですね。 https://medium.com/the-node-js-collection/node-js-17-is-here-8dba1e14e382 対策 If you hit an ERR_OSSL_EVP_UNSUPPORTED error in your application with Node.js 17, it’s likely that your application or a module you’re using is attempting to use an algorithm or key size which is no longer allowed by default with OpenSSL 3.0. A new command-line option, --openssl-legacy-provider, has been added to revert to the legacy provider as a temporary workaround for these tightened restrictions. OpenSSL3.0が使われる前に用いられていたもの(プロバイダー?)に戻すオプションがあるので、一時的にはこれを使うのがいい。 export NODE_OPTIONS=--openssl-legacy-provider いけたぁ
  • このエントリーをはてなブックマークに追加
  • Qiitaで続きを読む

npm を使用したインストールで「permission denied, access」が出た

はじまり npmでのインストールができない。 npm install -g @vue/cli  以下のようなエラーが出た npm ERR! code EACCES npm ERR! syscall access npm ERR! path /usr/local/lib/node_modules npm ERR! errno -13 npm ERR! Error: EACCES: permission denied, access '/usr/local/lib/node_modules' npm ERR! [Error: EACCES: permission denied, access '/usr/local/lib/node_modules'] { npm ERR! errno: -13, npm ERR! code: 'EACCES', npm ERR! syscall: 'access', npm ERR! path: '/usr/local/lib/node_modules' npm ERR! } npm ERR! npm ERR! The operation was rejected by your operating system. npm ERR! It is likely you do not have the permissions to access this file as the current user npm ERR! npm ERR! If you believe this might be a permissions issue, please double-check the npm ERR! permissions of the file and its containing directories, or try running npm ERR! the command again as root/Administrator. npm ERR! A complete log of this run can be found in: npm ERR! /Users/〜〜〜〜〜〜〜/.npm/_logs/2021-11-27T03_37_32_265Z-debug.log 対策 同じような問題に遭遇した記事を発見 https://qiita.com/okohs/items/ced3c3de30af1035242d 公式ドキュメントにもエラーの対処法がある https://docs.npmjs.com/resolving-eacces-permissions-errors-when-installing-packages-globally どうやらさnodejsを再度インストールするのが推奨らしい 再インストールする しっかり記事を読まずに再インストールしたらうまくいかなかった この記事参考にしてアンインストールし、普通にインストールし直した。 https://qiita.com/nanbuwks/items/7d1baa3b06b7af169330 もう一度試す node:internal/bootstrap/switches/does_own_process_state:126 cachedCwd = rawMethods.cwd(); ^ Error: ENOENT: no such file or directory, uv_cwd at process.wrappedCwd (node:internal/bootstrap/switches/does_own_process_state:126:28) at process.cwd (/usr/local/lib/node_modules/npm/node_modules/graceful-fs/polyfills.js:10:19) at new Config (/usr/local/lib/node_modules/npm/node_modules/@npmcli/config/lib/index.js:92:19) at new <anonymous> (/usr/local/lib/node_modules/npm/lib/npm.js:83:19) at Object.<anonymous> (/usr/local/lib/node_modules/npm/lib/npm.js:71:30) at Module._compile (node:internal/modules/cjs/loader:1101:14) at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10) at Module.load (node:internal/modules/cjs/loader:981:32) at Function.Module._load (node:internal/modules/cjs/loader:822:12) at Module.require (node:internal/modules/cjs/loader:1005:19) { errno: -2, code: 'ENOENT', syscall: 'uv_cwd' } なんだこれ... ターミナル再起動してもう一度実行 とりあえずエラーメッセージ貼り付けてググってみたら、npmではないけれど、似たようなエラーの出てきている人がいた。ターミナル立ち上げ直したら動いたらしいのでやってみる。 https://teratail.com/questions/67522 npm notice npm notice New patch version of npm available! 8.1.0 -> 8.1.4 npm notice Changelog: https://github.com/npm/cli/releases/tag/v8.1.4 npm notice Run npm install -g npm@8.1.4 to update! npm notice npm ERR! code EACCES npm ERR! syscall mkdir npm ERR! path /usr/local/lib/node_modules/@vue npm ERR! errno -13 npm ERR! Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/@vue' npm ERR! [Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/@vue'] { npm ERR! errno: -13, npm ERR! code: 'EACCES', npm ERR! syscall: 'mkdir', npm ERR! path: '/usr/local/lib/node_modules/@vue' npm ERR! } npm ERR! npm ERR! The operation was rejected by your operating system. npm ERR! It is likely you do not have the permissions to access this file as the current user npm ERR! npm ERR! If you believe this might be a permissions issue, please double-check the npm ERR! permissions of the file and its containing directories, or try running npm ERR! the command again as root/Administrator. npm ERR! A complete log of this run can be found in: npm ERR! /Users/matsuokahikaru/.npm/_logs/2021-11-27T03_53_56_693Z-debug.log また似たようなエラーが。ここで、安直にインストールし直してもダメなのだと痛感し、ちゃんと調べることにした。 公式ドキュメント読んでインストールし直す どうやらnvmを使ってnodeとnpmをインストールすると、permissionの問題は回避できるらしいので、nvmをインストールする。 ソース https://github.com/nvm-sh/nvm#installing-and-updating Readmeに書いてあるコマンドを実行 curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash nvm -v command not foundが出ました。以下のコマンドを実行したら無事動きました。 source ~/.bash_profile npmをインストールする nvm install stable --latest-npm npm install -g @vue/cli  いけたぁ
  • このエントリーをはてなブックマークに追加
  • Qiitaで続きを読む

yarn installでエラーが出た件

今回、個人開発している方のお手伝いでVueを使用することになり、環境構築時のyarn installでエラーとなってしまいました。 その際に解決策として行ったことを記録として残しておこうと思います。 開発環境 PC:MacBook エディター:VSCode 以前一度Reactの環境構築を行っているので、Nodeはインストールされていました。 エラー発生時の状況 GitHubからダウンロードしたソースコードを開く。 下記のコマンドを実行 $yarn install しかし下記のエラーとなり失敗しました。 The engine "node" is incompatible with this module. Expected version "^10.13.0 || ^12.13.0 || ^14.17.0 || >=15.0.0". Got "14.16.1" 02 error Found incompatible module. 03 info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command. nodeのバージョンが非互換であるので、互換性のあるnodeをインストールしてくださいとのこと。 対処 互換性のあるNodeのインストール 下記のコマンドを実行して互換性のあるnodeをインストールしました。 $node install 14.17.0 Nodeのバージョンを確認 $node -v v14.16.1 あれ?バージョンが変わっていない・・・ 使用するNodeの切り替えコマンド実施 $nodebrew use 14.17.0 その後、バージョンを確認 $node -v 14.17.0 バージョンが切り替わったことを確認しました。 しかしyarn installでのエラーの状況は変わらず下記のまま・・・ The engine "node" is incompatible with this module. Expected version "^10.13.0 || ^12.13.0 || ^14.17.0 || >=15.0.0". Got "14.16.1" 02 error Found incompatible module. 03 info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command. 3.パスを通す ググったところ、パスを通す処理をしていませんでしたので下記を実行。 ~/.zshrcに下記の記載を追記し手保存します。 ~/.zshrc export PATH=$HOME/.nodebrew/current/bin:$PATH 下記のコマンド実行 source ~/.zshrc これでyarn install 実行 インストールが出来たことを確認! yarn serveコマンドを実行し、デバッグ環境が出来たことを確認しました。 参考サイト 参考qiita yarn実行時に「 The engine “node” is incompatible with this module.」エラーが発生した場合の対処方法
  • このエントリーをはてなブックマークに追加
  • Qiitaで続きを読む