簡體   English   中英

npm 在 linux 上安裝失敗

[英]npm install fails on linux

剛開始學習vue的課程,所以對node完全不熟悉。 我所知道的是,當我第一次克隆課程的 repo 時,我按照說明進行操作,一切順利,運行沒有問題。 由於錯誤地運行 npm 構建,這弄亂了我克隆的文件夾結構,所以我刪除了整個文件夾並重新克隆它,現在 npm 安裝失敗,我無法弄清楚發生了什么。

這是我運行 npm 安裝時返回的內容,我可以確認我在正確的文件夾中:

Building: /usr/bin/node /home/rob/Development/vue-getting-started/02-getting-started/end/vue-heroes/node_modules/node-gyp/bin/node-gyp.js rebuild --verbose --libsass_ext= --libsass_cflags= --libsass_ldflags= --libsass_library=
gyp info it worked if it ends with ok
gyp verb cli [
gyp verb cli   '/usr/bin/node',
gyp verb cli   '/home/rob/Development/vue-getting-started/02-getting-started/end/vue-heroes/node_modules/node-gyp/bin/node-gyp.js',
gyp verb cli   'rebuild',
gyp verb cli   '--verbose',
gyp verb cli   '--libsass_ext=',
gyp verb cli   '--libsass_cflags=',
gyp verb cli   '--libsass_ldflags=',
gyp verb cli   '--libsass_library='
gyp verb cli ]
gyp info using node-gyp@3.8.0
gyp info using node@14.15.4 | linux | x64
gyp verb command rebuild []
gyp verb command clean []
gyp verb clean removing "build" directory
gyp verb command configure []
gyp verb check python checking for Python executable "/home/rob/anaconda3/bin/python3" in the PATH
gyp verb `which` succeeded /home/rob/anaconda3/bin/python3 /home/rob/anaconda3/bin/python3
gyp ERR! configure error 
gyp ERR! stack Error: Command failed: /home/rob/anaconda3/bin/python3 -c import sys; print "%s.%s.%s" % sys.version_info[:3];
gyp ERR! stack   File "<string>", line 1
gyp ERR! stack     import sys; print "%s.%s.%s" % sys.version_info[:3];
gyp ERR! stack                       ^
gyp ERR! stack SyntaxError: invalid syntax
gyp ERR! stack 
gyp ERR! stack     at ChildProcess.exithandler (child_process.js:308:12)
gyp ERR! stack     at ChildProcess.emit (events.js:315:20)
gyp ERR! stack     at maybeClose (internal/child_process.js:1048:16)
gyp ERR! stack     at Socket.<anonymous> (internal/child_process.js:439:11)
gyp ERR! stack     at Socket.emit (events.js:315:20)
gyp ERR! stack     at Pipe.<anonymous> (net.js:673:12)
gyp ERR! System Linux 5.4.0-65-generic
gyp ERR! command "/usr/bin/node" "/home/rob/Development/vue-getting-started/02-getting-started/end/vue-heroes/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd /home/rob/Development/vue-getting-started/02-getting-started/end/vue-heroes/node_modules/node-sass
gyp ERR! node -v v14.15.4
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok 
Build failed with error code: 1
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.9 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.9: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! node-sass@4.12.0 postinstall: `node scripts/build.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the node-sass@4.12.0 postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/rob/.npm/_logs/2021-02-10T12_53_03_497Z-debug.log

我可以看到 python2.7 命令試圖運行,但我不知道為什么,我的 linux 盒子上的 python 來自 Anaconda3,它經常更新,過去 10 年來一直是我的主要 python3。 上次沒有失敗,所以我懷疑問題實際上是我安裝的 node.js,因為這是唯一真正的未知數,因為我對節點一無所知,只需按照 vue.js 站點上的安裝說明安裝節點,以下是我安裝的版本:

node --version
v14.15.4

npm --version
6.14.10

vue --version
@vue/cli 4.5.11

最后是我為課程克隆的 git 存儲庫:

 https://github.com/johnpapa/vue-getting-started

任何有關發生的事情的見解將不勝感激。

我通過清除緩存找到了解決此問題的方法,如下所示:

npm cache clean --force

manually deleting node modules package-lock.json

npm 安裝然后按預期工作。

暫無
暫無

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

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