如何修复 npm 错误!吉普 错误! stack TypeError:运行 npm link some-dep<Object> 时无法分配给对象“#

问题描述 投票:0回答:2

我正在尝试运行 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

Python 3.9.6

macOS 13.5.2

macos npm typeerror node-gyp npm-link
2个回答
1
投票

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


0
投票

添加

"node-gyp": "10.0.1",  "nan": "2.18.0"

还补充

"resolutions": { "nan": "2.18.0" }
package.json 为我解决了 Node.JS 20 构建失败问题

© www.soinside.com 2019 - 2024. All rights reserved.