如何修复npm错误!gyp ERR!stack TypeError:运行npm link some-dep时,无法分配给对象“#”的只读属性“cflags”< Object>

9vw9lbht  于 2023-10-19  发布在  其他
关注(0)|答案(1)|浏览(185)

我尝试运行npm link felca-runtime,得到了下面的错误,我在网上找不到任何有用的东西:

theo.hodges@DKH334L0G5 felca-nhsuk % npm link felca-runtime
npm notice Beginning October 4, 2021, all connections to the npm registry - including for package installation - must use TLS 1.2 or higher. You are currently using plaintext http to connect. Please visit the GitHub blog for more information: https://github.blog/2021-08-23-npm-registry-deprecating-tls-1-0-tls-1-1/
npm notice Beginning October 4, 2021, all connections to the npm registry - including for package installation - must use TLS 1.2 or higher. You are currently using plaintext http to connect. Please visit the GitHub blog for more information: https://github.blog/2021-08-23-npm-registry-deprecating-tls-1-0-tls-1-1/
npm WARN deprecated [email protected]: this library is no longer supported
npm WARN deprecated [email protected]: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
npm WARN deprecated [email protected]: request has been deprecated, see https://github.com/request/request/issues/3142
npm ERR! code 1
npm ERR! path /Users/theo.hodges/accelerate/felca-nhsuk/node_modules/node-sass
npm ERR! command failed
npm ERR! command sh -c node scripts/build.js
npm ERR! Building: /Users/theo.hodges/.nvm/versions/node/v20.7.0/bin/node /Users/theo.hodges/accelerate/felca-nhsuk/node_modules/node-gyp/bin/node-gyp.js rebuild --verbose --libsass_ext= --libsass_cflags= --libsass_ldflags= --libsass_library=
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp verb cli [
npm ERR! gyp verb cli   '/Users/theo.hodges/.nvm/versions/node/v20.7.0/bin/node',
npm ERR! gyp verb cli   '/Users/theo.hodges/accelerate/felca-nhsuk/node_modules/node-gyp/bin/node-gyp.js',
npm ERR! gyp verb cli   'rebuild',
npm ERR! gyp verb cli   '--verbose',
npm ERR! gyp verb cli   '--libsass_ext=',
npm ERR! gyp verb cli   '--libsass_cflags=',
npm ERR! gyp verb cli   '--libsass_ldflags=',
npm ERR! gyp verb cli   '--libsass_library='
npm ERR! gyp verb cli ]
npm ERR! gyp info using [email protected]
npm ERR! gyp info using [email protected] | darwin | arm64
npm ERR! gyp verb command rebuild []
npm ERR! gyp verb command clean []
npm ERR! gyp verb clean removing "build" directory
npm ERR! gyp verb command configure []
npm ERR! gyp verb find Python Python is not set from command line or npm configuration
npm ERR! gyp verb find Python Python is not set from environment variable PYTHON
npm ERR! gyp verb find Python checking if "python3" can be used
npm ERR! gyp verb find Python - executing "python3" to get executable path
npm ERR! gyp verb find Python - executable path is "/Library/Developer/CommandLineTools/usr/bin/python3"
npm ERR! gyp verb find Python - executing "/Library/Developer/CommandLineTools/usr/bin/python3" to get version
npm ERR! gyp verb find Python - version is "3.9.6"
npm ERR! gyp info find Python using Python version 3.9.6 found at "/Library/Developer/CommandLineTools/usr/bin/python3"
npm ERR! gyp verb get node dir no --target version specified, falling back to host node version: 20.7.0
npm ERR! gyp verb command install [ '20.7.0' ]
npm ERR! gyp verb install input version string "20.7.0"
npm ERR! gyp verb install installing version: 20.7.0
npm ERR! gyp verb install --ensure was passed, so won't reinstall if already installed
npm ERR! gyp verb install version is already installed, need to check "installVersion"
npm ERR! gyp verb got "installVersion" 9
npm ERR! gyp verb needs "installVersion" 9
npm ERR! gyp verb install version is good
npm ERR! gyp verb get node dir target node version installed: 20.7.0
npm ERR! gyp verb build dir attempting to create "build" dir: /Users/theo.hodges/accelerate/felca-nhsuk/node_modules/node-sass/build
npm ERR! gyp verb build dir "build" dir needed to be created? /Users/theo.hodges/accelerate/felca-nhsuk/node_modules/node-sass/build
npm ERR! gyp verb build/config.gypi creating config file
npm ERR! gyp ERR! UNCAUGHT EXCEPTION 
npm ERR! gyp ERR! stack TypeError: Cannot assign to read only property 'cflags' of object '#<Object>'
npm ERR! gyp ERR! stack     at createConfigFile (/Users/theo.hodges/accelerate/felca-nhsuk/node_modules/node-gyp/lib/configure.js:117:21)
npm ERR! gyp ERR! stack     at /Users/theo.hodges/accelerate/felca-nhsuk/node_modules/node-gyp/lib/configure.js:84:9
npm ERR! gyp ERR! stack     at FSReqCallback.oncomplete (node:fs:189:23)
npm ERR! gyp ERR! System Darwin 22.6.0
npm ERR! gyp ERR! command "/Users/theo.hodges/.nvm/versions/node/v20.7.0/bin/node" "/Users/theo.hodges/accelerate/felca-nhsuk/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
npm ERR! gyp ERR! cwd /Users/theo.hodges/accelerate/felca-nhsuk/node_modules/node-sass
npm ERR! gyp ERR! node -v v20.7.0
npm ERR! gyp ERR! node-gyp -v v7.1.2
npm ERR! gyp ERR! Node-gyp failed to build your package.
npm ERR! gyp ERR! Try to update npm and/or node-gyp and if it does not help file an issue with the package author.
npm ERR! Build failed with error code: 7

npm ERR! A complete log of this run can be found in: /Users/theo.hodges/.npm/_logs/2023-09-22T08_52_11_799Z-debug-0.log

我试过更新npm,node-gyp,Python和清除npm缓存都无济于事。
我在跑步:
节点v20.7.0
npm 10.1.0
node-gyp v9.4.0
简体中文
macOS 13.5.2

sr4lhrrt

sr4lhrrt1#

在您的例子中,可能您安装了两个不同版本的node-sass,而node-gyp试图使用错误的版本。要解决这个问题,请尝试卸载所有版本的node-sass,然后重新安装最新版本:如果您仍然遇到此问题,请尝试清除node-gyp缓存。最后,尝试全局重新下载node-gyp

相关问题