无法安装Node模块并在Mac M1上出现错误。

huangapple go评论91阅读模式
英文:

cannot install node modules and getting an error in Mac M1

问题

我正在尝试在我的新 Mac M1 上运行 npm i,但我遇到以下错误。如果有人能查看并提供解决方案,将不胜感激。

我尝试了几种解决方案,但最终还是遇到了相同的错误。

npm WARN deprecated @hapi/pinpoint@2.0.0: Moved to 'npm install @sideway/pinpoint'
npm ERR! code 1
npm ERR! path /Users/lsdinduruwage/Documents/ZP-Projects/ZIP_Portal_V2/node_modules/bufferutil
npm ERR! command failed
npm ERR! command sh -c node-gyp-build
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@3.8.0
npm ERR! gyp info using node@16.13.0 | darwin | arm64
npm ERR! gyp http GET https://nodejs.org/download/release/v16.13.0/node-v16.13.0-headers.tar.gz
npm ERR! (node:23716) Warning: Setting the NODE_TLS_REJECT_UNAUTHORIZED environment variable to '0' makes TLS

connections and HTTPS requests insecure by disabling certificate verification.

npm ERR! (Use `node --trace-warnings ...` to show where the warning was created)
npm ERR! gyp http 200 https://nodejs.org/download/release/v16.13.0/node-v16.13.0-headers.tar.gz
npm ERR! gyp WARN install got an error, rolling back install
npm ERR! gyp ERR! configure error 
npm ERR! gyp ERR! stack Error: aborted
npm ERR! gyp ERR! stack     at connResetException (node:internal/errors:691:14)
npm ERR! gyp ERR! stack     at TLSSocket.socketCloseListener (node:_http_client:407:19)
npm ERR! gyp ERR! stack     at TLSSocket.emit (node:events:402:35)
npm ERR! gyp ERR! stack     at node:net:687:12
npm ERR! gyp ERR! stack     at TCP.done (node:_tls_wrap:580:7)
npm ERR! gyp ERR! System Darwin 22.2.0
npm ERR! gyp ERR! command "/Users/lsdinduruwage/.nvm/versions/node/v16.13.0/bin/node" "/Users/lsdinduruwage/Documents/ZP-Projects/ZIP_Portal_V2/node_modules/.bin/node-gyp" "rebuild"
npm ERR! gyp ERR! cwd /Users/lsdinduruwage/Documents/ZP-Projects/ZIP_Portal_V2/node_modules/bufferutil
npm ERR! gyp ERR! node -v v16.13.0
npm ERR! gyp ERR! node-gyp -v v3.8.0
npm ERR! gyp ERR! not ok
npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/lsdinduruwage/.npm/_logs

/2023-01-04T06_09_45_617Z-debug.log

我还尝试了 npm i --force,但仍然遇到相同的错误。

英文:

I'm trying to npm i in my new Mac M1 and I get the below error. Appreciate if anyone can have a look and provide a solution.

I tried several solutions, but I ended up getting the same error.

npm WARN deprecated @hapi/pinpoint@2.0.0: Moved to 'npm install @sideway/pinpoint'
npm ERR! code 1
npm ERR! path /Users/lsdinduruwage/Documents/ZP-Projects/ZIP_Portal_V2/node_modules/bufferutil
npm ERR! command failed
npm ERR! command sh -c node-gyp-build
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@3.8.0
npm ERR! gyp info using node@16.13.0 | darwin | arm64
npm ERR! gyp http GET https://nodejs.org/download/release/v16.13.0/node-v16.13.0-headers.tar.gz
npm ERR! (node:23716) Warning: Setting the NODE_TLS_REJECT_UNAUTHORIZED environment variable to '0' makes TLS

connections and HTTPS requests insecure by disabling certificate verification.

npm ERR! (Use `node --trace-warnings ...` to show where the warning was created)
npm ERR! gyp http 200 https://nodejs.org/download/release/v16.13.0/node-v16.13.0-headers.tar.gz
npm ERR! gyp WARN install got an error, rolling back install
npm ERR! gyp ERR! configure error 
npm ERR! gyp ERR! stack Error: aborted
npm ERR! gyp ERR! stack     at connResetException (node:internal/errors:691:14)
npm ERR! gyp ERR! stack     at TLSSocket.socketCloseListener (node:_http_client:407:19)
npm ERR! gyp ERR! stack     at TLSSocket.emit (node:events:402:35)
npm ERR! gyp ERR! stack     at node:net:687:12
npm ERR! gyp ERR! stack     at TCP.done (node:_tls_wrap:580:7)
npm ERR! gyp ERR! System Darwin 22.2.0
npm ERR! gyp ERR! command "/Users/lsdinduruwage/.nvm/versions/node/v16.13.0/bin/node" "/Users/lsdinduruwage/Documents/ZP-Projects/ZIP_Portal_V2/node_modules/.bin/node-gyp" "rebuild"
npm ERR! gyp ERR! cwd /Users/lsdinduruwage/Documents/ZP-Projects/ZIP_Portal_V2/node_modules/bufferutil
npm ERR! gyp ERR! node -v v16.13.0
npm ERR! gyp ERR! node-gyp -v v3.8.0
npm ERR! gyp ERR! not ok
npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/lsdinduruwage/.npm/_logs

/2023-01-04T06_09_45_617Z-debug.log

I tried npm i --force as well. I get the same error.

答案1

得分: 1

npm cache clean --force

或者

npm cache clean

如果不起作用,然后手动搜索缓存文件夹并从**~/.npm**中删除。 大多数情况下,通过npm cache clean就可以了。它完美运行。

> 之后运行

npm cache verify

> 之后安装

npm install npm@latest -g

英文:

npm cache clean --force

or

npm cache clean

if it doesn't work then manually search the cache folder delete from ~/.npm . Maximum times it's done by npm cache clean It's work perfectly.

> After that run

npm cache verify

> After that install

npm install npm@latest -g

答案2

得分: -1

我的问题是由于Python版本3.引起的。降级到2.7后,它可以正常工作,然后重新安装了node-gyp在nodejs版本上(使用nvm)。

英文:

My problem was caused due to python version 3.. Downgraded to 2.7 and it works, after re-installing node-gyp on the version nodejs (using nvm).

huangapple
  • 本文由 发表于 2023年1月4日 14:17:03
  • 转载请务必保留本文链接:https://go.coder-hub.com/75001579.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定