npm install报错:node-sass@5.0.0 postinstall: `node scripts/build.js`
<p>npm install 不通过 异常信息如下:</p><div class="cnblogs_code">
<pre><span style="color: rgba(255, 0, 0, 1)">> node-sass@5.0.0 postinstall D:\workspaces\VSCode\ruoyi-ui\node_modules\node-sass
</span>> node scripts/<span style="color: rgba(0, 0, 0, 1)">build.js
Building: D:\Program Files\nodejs\node.exe D:\workspaces\VSCode\ruoyi</span>-ui\node_modules\node-gyp\bin\node-gyp.js rebuild --verbose --libsass_ext= --libsass_cflags= --libsass_ldflags= --libsass_library=<span style="color: rgba(0, 0, 0, 1)">
gyp info it worked </span><span style="color: rgba(0, 0, 255, 1)">if</span><span style="color: rgba(0, 0, 0, 1)"> it ends with ok
gyp verb cli [
gyp verb cli </span>'D:\\Program Files\\nodejs\\node.exe'<span style="color: rgba(0, 0, 0, 1)">,
gyp verb cli </span>'D:\\workspaces\\VSCode\\ruoyi-ui\\node_modules\\node-gyp\\bin\\node-gyp.js'<span style="color: rgba(0, 0, 0, 1)">,
gyp verb cli </span>'rebuild'<span style="color: rgba(0, 0, 0, 1)">,
gyp verb cli </span>'--verbose'<span style="color: rgba(0, 0, 0, 1)">,
gyp verb cli </span>'--libsass_ext='<span style="color: rgba(0, 0, 0, 1)">,
gyp verb cli </span>'--libsass_cflags='<span style="color: rgba(0, 0, 0, 1)">,
gyp verb cli </span>'--libsass_ldflags='<span style="color: rgba(0, 0, 0, 1)">,
gyp verb cli </span>'--libsass_library='<span style="color: rgba(0, 0, 0, 1)">
gyp verb cli ]
gyp info using node</span>-gyp@7.1.2<span style="color: rgba(0, 0, 0, 1)">
gyp info using node@</span>14.16.1 | win32 |<span style="color: rgba(0, 0, 0, 1)"> x64
gyp verb command rebuild []
gyp verb command clean []
gyp verb clean removing </span>"build"<span style="color: rgba(0, 0, 0, 1)"> directory
gyp verb command configure []
gyp verb find Python Python is not set from command line or npm configuration
gyp verb find Python Python is not set from environment variable PYTHON
gyp verb find Python checking </span><span style="color: rgba(0, 0, 255, 1)">if</span> "python3"<span style="color: rgba(0, 0, 0, 1)"> can be used
gyp verb find Python </span>- executing "python3"<span style="color: rgba(0, 0, 0, 1)"> to get executable path
gyp verb find Python </span>- "python3"<span style="color: rgba(0, 0, 0, 1)"> is not in PATH or produced an error
gyp verb find Python checking </span><span style="color: rgba(0, 0, 255, 1)">if</span> "python"<span style="color: rgba(0, 0, 0, 1)"> can be used
gyp verb find Python </span>- executing "python"<span style="color: rgba(0, 0, 0, 1)"> to get executable path
gyp verb find Python </span>- "python"<span style="color: rgba(0, 0, 0, 1)"> is not in PATH or produced an error
gyp verb find Python checking </span><span style="color: rgba(0, 0, 255, 1)">if</span> "python2"<span style="color: rgba(0, 0, 0, 1)"> can be used
gyp verb find Python </span>- executing "python2"<span style="color: rgba(0, 0, 0, 1)"> to get executable path
gyp verb find Python </span>- "python2"<span style="color: rgba(0, 0, 0, 1)"> is not in PATH or produced an error
gyp verb find Python checking </span><span style="color: rgba(0, 0, 255, 1)">if</span><span style="color: rgba(0, 0, 0, 1)"> Python is C:\Python37\python.exe
gyp verb find Python </span>- executing "C:\Python37\python.exe"<span style="color: rgba(0, 0, 0, 1)"> to get version
gyp verb find Python </span>- "C:\Python37\python.exe"<span style="color: rgba(0, 0, 0, 1)"> could not be run
gyp verb find Python checking </span><span style="color: rgba(0, 0, 255, 1)">if</span><span style="color: rgba(0, 0, 0, 1)"> Python is C:\Python27\python.exe
gyp verb find Python </span>- executing "C:\Python27\python.exe"<span style="color: rgba(0, 0, 0, 1)"> to get version
gyp verb find Python </span>- "C:\Python27\python.exe"<span style="color: rgba(0, 0, 0, 1)"> could not be run
gyp verb find Python checking </span><span style="color: rgba(0, 0, 255, 1)">if</span><span style="color: rgba(0, 0, 0, 1)"> the py launcher can be used to find Python
gyp verb find Python </span>- executing "py.exe"<span style="color: rgba(0, 0, 0, 1)"> to get Python executable path
gyp verb find Python </span>- "py.exe"<span style="color: rgba(0, 0, 0, 1)"> is not in PATH or produced an error
gyp ERR</span>!<span style="color: rgba(0, 0, 0, 1)"> find Python
gyp ERR</span>!<span style="color: rgba(0, 0, 0, 1)"> find Python Python is not set from command line or npm configuration
gyp ERR</span>!<span style="color: rgba(0, 0, 0, 1)"> find Python Python is not set from environment variable PYTHON
gyp ERR</span>! find Python checking <span style="color: rgba(0, 0, 255, 1)">if</span> "python3"<span style="color: rgba(0, 0, 0, 1)"> can be used
gyp ERR</span>! find Python - "python3"<span style="color: rgba(0, 0, 0, 1)"> is not in PATH or produced an error
gyp ERR</span>! find Python checking <span style="color: rgba(0, 0, 255, 1)">if</span> "python"<span style="color: rgba(0, 0, 0, 1)"> can be used
gyp ERR</span>! find Python - "python"<span style="color: rgba(0, 0, 0, 1)"> is not in PATH or produced an error
gyp ERR</span>! find Python checking <span style="color: rgba(0, 0, 255, 1)">if</span> "python2"<span style="color: rgba(0, 0, 0, 1)"> can be used
gyp ERR</span>! find Python - "python2"<span style="color: rgba(0, 0, 0, 1)"> is not in PATH or produced an error
gyp ERR</span>! find Python checking <span style="color: rgba(0, 0, 255, 1)">if</span><span style="color: rgba(0, 0, 0, 1)"> Python is C:\Python37\python.exe
gyp ERR</span>! find Python - "C:\Python37\python.exe"<span style="color: rgba(0, 0, 0, 1)"> could not be run
gyp ERR</span>! find Python checking <span style="color: rgba(0, 0, 255, 1)">if</span><span style="color: rgba(0, 0, 0, 1)"> Python is C:\Python27\python.exe
gyp ERR</span>! find Python - "C:\Python27\python.exe"<span style="color: rgba(0, 0, 0, 1)"> could not be run
gyp ERR</span>! find Python checking <span style="color: rgba(0, 0, 255, 1)">if</span><span style="color: rgba(0, 0, 0, 1)"> the py launcher can be used to find Python
gyp ERR</span>! find Python - "py.exe"<span style="color: rgba(0, 0, 0, 1)"> is not in PATH or produced an error
gyp ERR</span>!<span style="color: rgba(0, 0, 0, 1)"> find Python
gyp ERR</span>! find Python **********************************************************<span style="color: rgba(0, 0, 0, 1)">
gyp ERR</span>!<span style="color: rgba(0, 0, 0, 1)"> find Python You need to install the latest version of Python.
gyp ERR</span>! find Python Node-<span style="color: rgba(0, 0, 0, 1)">gyp should be able to find and use Python. If not,
gyp ERR</span>! find Python you can <span style="color: rgba(0, 0, 255, 1)">try</span><span style="color: rgba(0, 0, 0, 1)"> one of the following options:
gyp ERR</span>! find Python - Use the <span style="color: rgba(0, 0, 255, 1)">switch</span> --python="C:\Path\To\python.exe"<span style="color: rgba(0, 0, 0, 1)">
gyp ERR</span>! find Python (accepted by both node-<span style="color: rgba(0, 0, 0, 1)">gyp and npm)
gyp ERR</span>! find Python -<span style="color: rgba(0, 0, 0, 1)"> Set the environment variable PYTHON
gyp ERR</span>! find Python -<span style="color: rgba(0, 0, 0, 1)"> Set the npm configuration variable python:
gyp ERR</span>! find Python npm config set python "C:\Path\To\python.exe"<span style="color: rgba(0, 0, 0, 1)">
gyp ERR</span>!<span style="color: rgba(0, 0, 0, 1)"> find Python For more information consult the documentation at:
gyp ERR</span>! find Python https:<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">github.com/nodejs/node-gyp#installation</span>
gyp ERR! find Python **********************************************************<span style="color: rgba(0, 0, 0, 1)">
gyp ERR</span>!<span style="color: rgba(0, 0, 0, 1)"> find Python
gyp ERR</span>!<span style="color: rgba(0, 0, 0, 1)"> configure error
gyp ERR</span>!<span style="color: rgba(0, 0, 0, 1)"> stack Error: Could not find any Python installation to use
gyp ERR</span>! stack at PythonFinder.fail (D:\workspaces\VSCode\ruoyi-ui\node_modules\node-gyp\lib\find-python.js:302:47<span style="color: rgba(0, 0, 0, 1)">)
gyp ERR</span>! stack at PythonFinder.runChecks (D:\workspaces\VSCode\ruoyi-ui\node_modules\node-gyp\lib\find-python.js:136:21<span style="color: rgba(0, 0, 0, 1)">)
gyp ERR</span>! stack at PythonFinder.<anonymous> (D:\workspaces\VSCode\ruoyi-ui\node_modules\node-gyp\lib\find-python.js:200:18<span style="color: rgba(0, 0, 0, 1)">)
gyp ERR</span>! stack at PythonFinder.execFileCallback (D:\workspaces\VSCode\ruoyi-ui\node_modules\node-gyp\lib\find-python.js:266:16<span style="color: rgba(0, 0, 0, 1)">)
gyp ERR</span>! stack at exithandler (child_process.js:315:5<span style="color: rgba(0, 0, 0, 1)">)
gyp ERR</span>! stack at ChildProcess.errorhandler (child_process.js:327:5<span style="color: rgba(0, 0, 0, 1)">)
gyp ERR</span>! stack at ChildProcess.emit (events.js:315:20<span style="color: rgba(0, 0, 0, 1)">)
gyp ERR</span>! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:275:12<span style="color: rgba(0, 0, 0, 1)">)
gyp ERR</span>! stack at onErrorNT (internal/child_process.js:465:16<span style="color: rgba(0, 0, 0, 1)">)
gyp ERR</span>! stack at processTicksAndRejections (internal/process/task_queues.js:80:21<span style="color: rgba(0, 0, 0, 1)">)
gyp ERR</span>! System Windows_NT 10.0.18362<span style="color: rgba(0, 0, 0, 1)">
gyp ERR</span>! command "D:\\Program Files\\nodejs\\node.exe" "D:\\workspaces\\VSCode\\ruoyi-ui\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="<span style="color: rgba(0, 0, 0, 1)">
gyp ERR</span>! cwd D:\workspaces\VSCode\ruoyi-ui\node_modules\node-<span style="color: rgba(0, 0, 0, 1)">sass
gyp ERR</span>! node -v v14.16.1<span style="color: rgba(0, 0, 0, 1)">
gyp ERR</span>! node-gyp -v v7.1.2<span style="color: rgba(0, 0, 0, 1)">
gyp ERR</span>!<span style="color: rgba(0, 0, 0, 1)"> not ok
Build failed with error code: </span>1<span style="color: rgba(0, 0, 0, 1)">
npm WARN eslint</span>-loader@2.2.1 requires a peer of eslint@>=1.6.0 <7.0.0<span style="color: rgba(0, 0, 0, 1)"> but none is installed. You must install peer dependencies yourself.
npm WARN less</span>-loader@8.1.0 requires a peer of webpack@^5.0.0<span style="color: rgba(0, 0, 0, 1)"> but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@</span>2.3.2<span style="color: rgba(0, 0, 0, 1)"> (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform </span><span style="color: rgba(0, 0, 255, 1)">for</span> fsevents@2.3.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"<span style="color: rgba(0, 0, 0, 1)">})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@</span>1.2.13 (node_modules\webpack-dev-<span style="color: rgba(0, 0, 0, 1)">server\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform </span><span style="color: rgba(0, 0, 255, 1)">for</span> fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"<span style="color: rgba(0, 0, 0, 1)">})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@</span>1.2.13 (node_modules\watchpack-<span style="color: rgba(0, 0, 0, 1)">chokidar2\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform </span><span style="color: rgba(0, 0, 255, 1)">for</span> fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"<span style="color: rgba(0, 0, 0, 1)">})
npm ERR</span>!<span style="color: rgba(0, 0, 0, 1)"> code ELIFECYCLE
npm ERR</span>! errno 1<span style="color: rgba(255, 0, 0, 1)">
npm ERR! node-sass@5.0.0 postinstall: `node scripts/</span><span style="color: rgba(0, 0, 0, 1)"><span style="color: rgba(255, 0, 0, 1)">build.js`
</span>npm ERR</span>! Exit status 1<span style="color: rgba(0, 0, 0, 1)">
npm ERR</span>!<span style="color: rgba(0, 0, 0, 1)">
npm ERR</span>! Failed at the node-sass@5.0.0<span style="color: rgba(0, 0, 0, 1)"> postinstall script.
npm ERR</span>!<span style="color: rgba(0, 0, 0, 1)"> This is probably not a problem with npm. There is likely additional logging output above.
npm ERR</span>! A complete log of <span style="color: rgba(0, 0, 255, 1)">this</span> run can be found in:</pre>
</div>
<p> </p>
<p>很多人会以为是 python 找不到,而去安装python 然后各种<span style="color: rgba(0, 128, 128, 1)"> 管理员权限打开执行:npm install --global --production windows-build-tools。</span></p>
<p>最后还是不行,仔细看会发现标红得错误信息,应该是 node-sass安装不成功 添加一个<code>node-sass</code> 的数据源,在install 就OK了</p>
<h3>解决方法:</h3>
<h3><strong><span style="color: rgba(255, 0, 0, 1)"> <span class="pln">npm config <span class="kwd">set<span class="pln"> sass_binary_site<span class="pun">=<span class="pln">https<span class="pun">:<span class="com">//npm.taobao.org/mirrors/node-sass</span></span></span></span></span></span></span></span></strong></h3>
<p><span style="color: rgba(0, 0, 0, 1)"><span class="pln"><span class="kwd"><span class="pln"><span class="pun"><span class="pln"><span class="pun"><span class="com">再执行 npm install 就可以了</span></span></span></span></span></span></span></span></p>
<p> </p><br><br>
来源:https://www.cnblogs.com/sandyyeh/p/15472398.html
頁:
[1]