简体   繁体   English

npm 在 linux 上安装失败

[英]npm install fails on linux

Just started a course learning vue, so I am completely unfamiliar with node.刚开始学习vue的课程,所以对node完全不熟悉。 All I know is that when I first cloned the repo for the course, I followed the instructions and it all went fine it ran no problem.我所知道的是,当我第一次克隆课程的 repo 时,我按照说明进行操作,一切顺利,运行没有问题。 Due to running npm build by mistake, this messed up the folder structure I had cloned, so I deleted the whole folder and recloned it, now npm install fails and I can't work out what is going on.由于错误地运行 npm 构建,这弄乱了我克隆的文件夹结构,所以我删除了整个文件夹并重新克隆它,现在 npm 安装失败,我无法弄清楚发生了什么。

This is what is returned when I run npm install, I can confirm that I am in the folder I am in the correct folder:这是我运行 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

I can see the python2.7 command trying to be run, but I don't know why, python on my linux box is from Anaconda3 which gets updated often and has been my staple python3 for the past 10 years.我可以看到 python2.7 命令试图运行,但我不知道为什么,我的 linux 盒子上的 python 来自 Anaconda3,它经常更新,过去 10 年来一直是我的主要 python3。 This did not fail last time, so I suspect the issue is actually with my install of node.js, as this is the only real unknown in that I know nothing at all about node and simply followed the install instructions on the vue.js site for installing node, of which here are the versions I have installed:上次没有失败,所以我怀疑问题实际上是我安装的 node.js,因为这是唯一真正的未知数,因为我对节点一无所知,只需按照 vue.js 站点上的安装说明安装节点,以下是我安装的版本:

node --version
v14.15.4

npm --version
6.14.10

vue --version
@vue/cli 4.5.11

and finally here is the git repo that I am cloning for the course:最后是我为课程克隆的 git 存储库:

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

Any insight as to what has happened would be much appreciated.任何有关发生的事情的见解将不胜感激。

I found a solution to this issue by clearing the cache as follows:我通过清除缓存找到了解决此问题的方法,如下所示:

npm cache clean --force

manually deleting node modules package-lock.json

npm install then worked as expected. npm 安装然后按预期工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM