簡體   English   中英

如何在 docker 容器中更新 Node.js? Laravel / 帆開發

[英]How to Update Node.js in docker container? Laravel / Sail developemnt

我在運行 npm run dev 時收到警告

sail npm run dev
npm does not support Node.js v15.10.0
You should probably upgrade to a newer version of node as we
can't make any promises that npm will work with this version.
You can find the latest version at https://nodejs.org/

該過程運行正常。 laravel mix is doing its job, creating the app.css, etc. However, having took notice, I decided to try to update Node.js in the docker container, so I did the following.

sail root-shell
apt update
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash
source ~/.bashrc
nvm --version
   0.38.0
nvm install 16.17.0
nvm ls             
->     v16.17.0
         system
default -> 16.17.0 (-> v16.17.0)
iojs -> N/A (default)
unstable -> N/A (default)
node -> stable (-> v16.17.0) (default)
stable -> 16.17 (-> v16.17.0) (default)
lts/* -> lts/gallium (-> v16.17.0)
lts/argon -> v4.9.1 (-> N/A)
lts/boron -> v6.17.1 (-> N/A)
lts/carbon -> v8.17.0 (-> N/A)
lts/dubnium -> v10.24.1 (-> N/A)
lts/erbium -> v12.22.12 (-> N/A)
lts/fermium -> v14.20.0 (-> N/A)
lts/gallium -> v16.17.0

所以看起來 Node.js 確實更新到了最新的穩定版本。 至少在帆根殼中。 我使用桌面應用程序停止了 docker 容器,然后重新啟動它。

但是,當我隨后發出sail npm --version 命令時,響應是相同的,即:

npm does not support Node.js v15.10.0
You should probably upgrade to a newer version of node as we
can't make any promises that npm will work with this version.

如果我在sail root-shell中更新Node.js版本,為什么“sail npm --version”命令不能識別Node.js版本已經更新?

作為補充信息,我在 php 風暴中使用了終端。 在調用航行命令之前,我發出

alias sail='bash vendor/bin/sail'

然后我可以使用較短的“sail npm -- 版本”語法。

簽了個糊塗。

好吧,閱讀文檔是值得的。 Laravel Sail 默認安裝節點版本 16。 如果您想要另一個版本,您需要對 docker.yml 文件進行簡單的更改。

更改 Laravel Sail 中的節點版本

build:
    args:
        WWWGROUP: '${WWWGROUP}'
        NODE_VERSION: '14'

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM