简体   繁体   中英

npm install fails on linux

Just started a course learning vue, so I am completely unfamiliar with 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. 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.

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:

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. 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 --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:

 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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