【发布时间】:2021-10-31 12:07:19
【问题描述】:
看,我安装了最新的节点版本
node -v // I get v14.15.0
然后我为一个小项目运行npm init。我还创建了一个 index.js 文件,代码如下
console.lo("Hello")
显然有错别字,应该是console.log("Hello"),但我这样做是为了得到项目使用的node和npm版本。
npm ERR! Linux 5.4.0-81-generic
npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "install" "-g" "npm@next"
npm ERR! node v8.10.0
npm ERR! npm v3.5.2
npm ERR! path /usr/local/lib/node_modules/.staging/@gar/promisify-ebaab35a
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall rename
它使用的是旧版本,但我想要最新的。我没有强迫使用旧版本
那么我如何 npm init 但使用最新版本的 node 和 npm。
另外,当我尝试使用 sudo npm install -g npm@next 更新 npm 时,我收到此错误
npm ERR! enoent ENOENT: no such file or directory, rename '/usr/local/lib/node_modules/.staging/@gar/promisify-ebaab35a' -> '/usr/local/lib/node_modules/npm/node_modules/@gar/promisify'
npm ERR! enoent ENOENT: no such file or directory, rename '/usr/local/lib/node_modules/.staging/@gar/promisify-ebaab35a' -> '/usr/local/lib/node_modules/npm/node_modules/@gar/promisify'
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.
npm ERR! enoent
npm ERR! Please include the following file with any support request:
npm ERR! /home/braulio/npm-debug.log
npm ERR! code 1
我认为 npm 正在强制 node 使用 v8.10,所以也许在我不更新 npm 之前,node 不会。我该如何解决这个问题?
【问题讨论】: