微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

npm install node-sass@latest 未安装并出现错误:无法下载“v5.0.0/linux_musl-x64-57_binding.node”:

如何解决npm install node-sass@latest 未安装并出现错误:无法下载“v5.0.0/linux_musl-x64-57_binding.node”:

在我的 docker 文件中,我尝试创建一个图像。 这是我的 Dockerfile:

FROM node:8.10.0-alpine
workdir /


ENV GLIBC_VERSION=2.32-r0
ENV JAVA_HOME=/opt/jdk1.8.0_211
ENV JRE_HOME=/opt/jdk1.8.0_211/jre
ENV JAVA_OPTS="-Dfile.encoding=UTF-8"
ENV PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$JAVA_OPTS:$PATH
ENV NPM_GLOBAL /.npm-global
ENV PATH ${NPM_GLOBAL}/bin:$PATH



RUN apk add --update \
      ca-certificates \
      wget \
      curl \
      git \
      openssh \
      bash && \
    # Install latest glibc
    wget --directory-prefix=/tmp https://github.com/andyshinn/alpine-pkg-glibc/releases/download/${GLIBC_VERSION}/glibc-${GLIBC_VERSION}.apk && \
    apk add --allow-untrusted /tmp/glibc-${GLIBC_VERSION}.apk && \
    wget --directory-prefix=/tmp https://github.com/andyshinn/alpine-pkg-glibc/releases/download/${GLIBC_VERSION}/glibc-bin-${GLIBC_VERSION}.apk && \
    apk add --allow-untrusted /tmp/glibc-bin-${GLIBC_VERSION}.apk && \
    wget --directory-prefix=/tmp https://github.com/andyshinn/alpine-pkg-glibc/releases/download/${GLIBC_VERSION}/glibc-i18n-${GLIBC_VERSION}.apk && \
    apk --allow-untrusted add /tmp/glibc-i18n-${GLIBC_VERSION}.apk && \
    /usr/glibc-compat/bin/localedef -i en_US -f UTF-8 en_US.UTF-8 && \


    
  ...
 
RUN npm cache clear --force
RUN npm install --global yo gulp
RUN npm install --global gulp-cli
RUN npm install --save-dev gulp
RUN npm i --save gulp-ruby-sass
RUN npm install node-sass@latest

RUN npm update
RUN npm rebuild node-sass

尝试下载时 saas 安装被阻止: 从 https://github.com/sass/node-sass/releases/download/v5.0.0/linux_musl-x64-57_binding.node 下载二进制文件 【91m无法下载"https://github.com/sass/node-sass/releases/download/v5.0.0/linux_musl-x64-57_binding.node":

现在不可用了。 看这里: https://github.com/sass/node-sass/releases

这是输出

Step 19/25 : RUN npm install node-sass@latest
 ---> Running in aff763880e27
[91mnpm WARN deprecated request@2.88.2: request has been deprecated,see https://github.com/request/request/issues/3142
[0m[91mnpm WARN deprecated har-validator@5.1.5: this library is no longer supported
[0m
> node-sass@5.0.0 install /node_modules/node-sass
> node scripts/install.js

Downloading binary from https://github.com/sass/node-sass/releases/download/v5.0.0/linux_musl-x64-57_binding.node
[91mCannot download "https://github.com/sass/node-sass/releases/download/v5.0.0/linux_musl-x64-57_binding.node": 

HTTP error 404 Not Found

Hint: If github.com is not accessible in your location
      try setting a proxy via HTTP_PROXY,e.g. 

      export HTTP_PROXY=http://example.com:1234

or configure npm proxy via

      npm config set proxy http://example.com:8080
[0m
> node-sass@5.0.0 postinstall /node_modules/node-sass
> node scripts/build.js

Building: /usr/local/bin/node /node_modules/node-gyp/bin/node-gyp.js rebuild --verbose --libsass_ext= --libsass_cflags= --libsass_ldflags= --libsass_library=
[91mgyp[0m[91m info it worked if it ends with ok
[0m[91mgyp verb cli [ '/usr/local/bin/node',[0m[91mgyp verb cli   '/node_modules/node-gyp/bin/node-gyp.js',gyp [0m[91mverb [0m[91mcli   'rebuild',gyp verb cli[0m[91m   '--verbose',[0m[91mgyp verb cli[0m[91m   '--libsass_ext=',[0m[91mgyp verb cli   '--libsass_cflags=',gyp verb[0m[91m cli   '--libsass_ldflags=',gyp[0m[91m verb cli[0m[91m   '--libsass_library=' ]
[0m[91mgyp info using node-gyp@7.1.2
[0m[91mgyp [0m[91minfo using[0m[91m node@8.10.0 | linux | x64
[0m[91mgyp verb command rebuild []
[0m[91mgyp verb command clean []
[0m[91mgyp verb clean removing "build" directory
[0m[91mgyp verb command configure []
[0m[91mgyp verb find Python Python is not set from command line or npm configuration
[0m[91mgyp verb [0m[91mfind Python Python is not set from environment variable PYTHON
[0m[91mgyp verb [0m[91mfind Python checking if "python3" can be used
[0m[91mgyp verb find Python - executing "python3" to get executable path
[0m[91mgyp verb find Python - "python3" is not in PATH or produced an error
gyp [0m[91mverb find Python checking if "python" can be used
gyp verb find Python[0m[91m - executing "python" to get executable path
[0m[91mgyp verb find Python - "python" is not in PATH or produced an error
[0m[91mgyp verb find Python checking if "python2" can be used
gyp verb[0m[91m find Python - executing "python2" to get executable path
[0m[91mgyp verb find Python - "python2" is not in PATH or produced an error
[0m[91mgyp ERR! find Python 
gyp [0m[91mERR! find Python Python is not set from command line or npm configuration
gyp [0m[91mERR![0m[91m find Python Python is not set from environment variable PYTHON
gyp ERR! find Python checking if "python3" can be used
gyp[0m[91m ERR! find Python - "python3" is not in PATH or produced an error
gyp[0m[91m [0m[91mERR! [0m[91mfind Python checking if "python" can be used
[0m[91mgyp ERR![0m[91m find Python - "python" is not in PATH or produced an error
[0m[91mgyp [0m[91mERR! find Python checking if "python2" can be used
gyp ERR![0m[91m [0m[91mfind Python - "python2" is not in PATH or produced an error
[0m[91mgyp[0m[91m ERR![0m[91m find Python 
[0m[91mgyp ERR![0m[91m find Python[0m[91m **********************************************************
gyp ERR! [0m[91mfind Python You need to install the latest version of Python.
[0m[91mgyp ERR! find Python Node-gyp should be able to find and use Python. If not,gyp[0m[91m ERR! find Python[0m[91m you can try one of the following options:
gyp ERR![0m[91m find Python - Use the switch --python="/path/to/pythonexecutable"
[0m[91mgyp ERR![0m[91m find Python   (accepted by both node-gyp and npm)
gyp ERR! find Python - Set the environment variable PYTHON
gyp ERR! [0m[91mfind Python - Set the npm configuration variable python:
gyp[0m[91m ERR! [0m[91mfind Python   npm config set python "/path/to/pythonexecutable"
gyp ERR![0m[91m find Python[0m[91m For more information consult the documentation at:
gyp ERR![0m[91m find Python https://github.com/nodejs/node-gyp#installation
gyp[0m[91m ERR! find Python[0m[91m **********************************************************
gyp ERR! find Python[0m[91m 
[0m[91mgyp ERR! configure error 
[0m[91mgyp ERR! stack Error: Could not find any Python installation to use
gyp ERR! stack     at PythonFinder.fail (/node_modules/node-gyp/lib/find-python.js:302:47)
[0m[91mgyp ERR! [0m[91mstack     at PythonFinder.runchecks (/node_modules/node-gyp/lib/find-python.js:136:21)
gyp [0m[91mERR! stack     at PythonFinder.<anonymous> (/node_modules/node-gyp/lib/find-python.js:179:16)
[0m[91mgyp [0m[91mERR! [0m[91mstack     at PythonFinder.execFileCallback (/node_modules/node-gyp/lib/find-python.js:266:16)
[0m[91mgyp [0m[91mERR! [0m[91mstack     at exithandler (child_process.js:282:5)
[0m[91mgyp ERR! stack     at ChildProcess.errorhandler (child_process.js:294:5)
[0m[91mgyp ERR![0m[91m stack     at emitOne (events.js:116:13)
[0m[91mgyp ERR! stack     at ChildProcess.emit (events.js:211:7)
gyp[0m[91m ERR! [0m[91mstack     at Process.ChildProcess._handle.onexit (internal/child_process.js:196:12)
[0m[91mgyp ERR![0m[91m stack     at onErrorNT (internal/child_process.js:372:16)
[0m[91mgyp ERR! [0m[91mSystem Linux 4.15.0-1087-gcp
[0m[91mgyp ERR! command "/usr/local/bin/node" "/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
[0m[91mgyp ERR! [0m[91mcwd[0m[91m /node_modules/node-sass
[0m[91mgyp ERR! node -v v8.10.0
[0m[91mgyp ERR! [0m[91mnode-gyp -v v7.1.2
[0m[91mgyp ERR! not ok 
[0m[91mBuild Failed with error code: 1
[0m[91mnpm WARN enoent ENOENT: no such file or directory,open '/package.json'
[0m[91mnpm WARN !invalid#1 No description
npm WARN !invalid#1 No repository field.
npm WARN[0m[91m !invalid#1 No README data
npm WARN !invalid#1 No license field.
[0m[91mnpm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.13 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
[0m[91m
[0m[91mnpm ERR! code ELIFECYCLE
[0m[91mnpm ERR! errno 1
[0m[91mnpm ERR! node-sass@5.0.0 postinstall: `node scripts/build.js`
npm ERR! Exit status 1
npm ERR![0m[91m 
npm ERR! Failed at the node-sass@5.0.0 postinstall script.
npm[0m[91m ERR! This is probably not a problem with npm. There is likely additional logging output above.
[0m[91m
npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2021-02-19T13_12_12_157Z-debug.log
[0mThe command '/bin/sh -c npm install node-sass@latest' returned a non-zero code: 1
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // node
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Push Image)
Stage "Push Image" skipped due to earlier failure(s)
[Pipeline] }
[Pipeline] // stage
[Pipeline] End of Pipeline
ERROR: script returned exit code 1
Finished: FAILURE

如何指定这一步?

运行 npm install node-sass@latest

提前致谢。

解决方法

node-sass v5 不再支持 Node 8,因为它是 EOL https://github.com/sass/node-sass#node-version-support-policy

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。