Hướng dẫn node-gyp env: python: no such file or directory - node-gyp env: python: không có tệp hoặc thư mục nào như vậy

2

Mới! Lưu câu hỏi hoặc câu trả lời và sắp xếp nội dung yêu thích của bạn. Tìm hiểu thêm.
Learn more.

Tôi đang cố gắng cài đặt NPM và tôi đang gặp lỗi trong ứng dụng của mình

Chi tiết hệ thống: MacOS Monterey: Phiên bản 12.5

Chip Apple M1 Pro

Phiên bản nút: 14.19.3

Phiên bản Node-Gyp: 9.1.0

Phiên bản Python: 3.8.9

>  install /Users/sanhp/client-access-portal/node_modules/snappy
> prebuild-install || node-gyp rebuild

prebuild-install WARN install No prebuilt binaries found (target=14.19.3 runtime=node arch=arm64 libc= platform=darwin)
  CXX(target) Release/obj.target/snappy/deps/snappy/snappy-1.1.7/snappy-sinksource.o
  CXX(target) Release/obj.target/snappy/deps/snappy/snappy-1.1.7/snappy-stubs-internal.o
  CXX(target) Release/obj.target/snappy/deps/snappy/snappy-1.1.7/snappy.o
  LIBTOOL-STATIC Release/snappy.a
env: python: No such file or directory
make: *** [Release/snappy.a] Error 127
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/Users/sanhp/.nvm/versions/node/v14.19.3/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)
gyp ERR! stack     at ChildProcess.emit (events.js:400:28)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:285:12)
gyp ERR! System Darwin 21.6.0
gyp ERR! command "/Users/sanhp/.nvm/versions/node/v14.19.3/bin/node" "/Users/sanhp/.nvm/versions/node/v14.19.3/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/sanhp/client-access-portal/node_modules/snappy
gyp ERR! node -v v14.19.3
gyp ERR! node-gyp -v v5.1.0
gyp ERR! not ok
 

Hỏi ngày 16 tháng 8 lúc 4:13Aug 16 at 4:13

Hướng dẫn node-gyp env: python: no such file or directory - node-gyp env: python: không có tệp hoặc thư mục nào như vậy

Cài đặt NPM đang phàn nàn rằng nó không thể tìm thấy Python trong môi trường. Để xác nhận đó là trường hợp chạy lệnh sau

python --version

Bạn sẽ nhận được một lệnh không tìm thấy ngoại lệ. Để giải quyết cài đặt Python sau đó chạy lệnh trên sẽ cho bạn biết phiên bản Python được cài đặt. Một số phiên bản của Python có tên nhị phân hơi khác nhau, ví dụ Python3 vì vậy tôi khuyên bạn nên cài đặt PyenV có thể được sử dụng để quản lý nhiều phiên bản Python. Thực hiện theo các hướng dẫn trong readme để cài đặt pyenv và python. Khi lệnh trước đó trả về phiên bản Python, bạn có thể thử lại 'NPM Cài đặt'.

Đã trả lời ngày 1 tháng 9 lúc 7:00Sep 1 at 7:00

3

NPM ERR! Mã 1 NPM ERR! đường dẫn/người dùng/petersenrr/dev/qa-brightspot/node_modules/node-expat npm err! Lệnh không thành công NPM ERR! lệnh sh -c node -gyp xây dựng lại npm err! CC (Target) Phát hành/obj.target/expat/deps/libexpat/lib/xmlparse.o npm err! CC (Target) Phát hành/obj.target/expat/deps/libexpat/lib/xmltok.o npm err! CC (Target) Phát hành/obj.target/expat/deps/libexpat/lib/xmlrole.o npm err! LIBTOOL-STATIC RELEONS/LIBEXPAT.A NPM ERR! Thông tin gyp Nó hoạt động nếu nó kết thúc với OK NPM ERR! Thông tin gyp bằng NPM ERR! Thông tin gyp bằng cách sử dụng | Darwin | x64 NPM ERR! Thông tin gyp Tìm Python bằng phiên bản Python 3.10.3 được tìm thấy tại "/l Library . Trong tương lai, tài sản sẽ chỉ được đọc. NPM ERR! (Sử dụng node --trace-deprecation ... để hiển thị nơi cảnh báo được tạo) NPM ERR! thông tin gyp spawn /l Library/frameWorks/python.framework/versions/3.10/bin/python3 npm err! Thông tin Gyp Spawn args [NPM ERR! thông tin gyp spawn args '/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py', npm err! Thông tin gyp Spawn args 'Binding.gyp', NPM ERR! Gyp Info Spawn args '-f', npm err! Gyp Info Spawn Args 'Make', NPM ERR! Thông tin gyp sinh sản args '-i', npm err! thông tin gyp spawn args '/Users/petersenrr/dev/qa-rightspot/node_modules/node-expat/build/config.gypi', npm err! Thông tin gyp sinh sản args '-i', npm err! thông tin gyp spawn args '/usr/local/lib/node_modules/npm/node_modules/node-gyp/addon.gypi', npm err! Thông tin gyp sinh sản args '-i', npm err! GYP Info Spawn args '/Users/petersenrr/l Library/caches/node-gyp/16.4.1/include/node/common.gypi', npm err! thông tin gyp spawn args '-dl Library = shared_l Library', npm err! GYP Info Spawn args '-dvisibility = mặc định', npm err! Thông tin gyp spawn args '-dnode_root_dir =/người dùng/petersenrr/thư viện/cache/node-gyp/16.4.1', npm err! thông tin gyp spawn args '-dnode_gyp_dir =/usr/local/lib/node_modules/npm/node_modules/node-gyp', npm err! Thông tin gyp Spawn args '-dnode_lib_file =/người dùng/petersenrr/thư viện/caches/node-gyp/16.4.1/
npm ERR! path /Users/Petersenrr/dev/qa-brightspot/node_modules/node-expat
npm ERR! command failed
npm ERR! command sh -c node-gyp rebuild
npm ERR! CC(target) Release/obj.target/expat/deps/libexpat/lib/xmlparse.o
npm ERR! CC(target) Release/obj.target/expat/deps/libexpat/lib/xmltok.o
npm ERR! CC(target) Release/obj.target/expat/deps/libexpat/lib/xmlrole.o
npm ERR! LIBTOOL-STATIC Release/libexpat.a
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using
npm ERR! gyp info using | darwin | x64
npm ERR! gyp info find Python using Python version 3.10.3 found at "/Library/Frameworks/Python.framework/Versions/3.10/bin/python3"
npm ERR! (node:11296) [DEP0150] DeprecationWarning: Setting process.config is deprecated. In the future the property will be read-only.
npm ERR! (Use node --trace-deprecation ... to show where the warning was created)
npm ERR! gyp info spawn /Library/Frameworks/Python.framework/Versions/3.10/bin/python3
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args '/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
npm ERR! gyp info spawn args 'binding.gyp',
npm ERR! gyp info spawn args '-f',
npm ERR! gyp info spawn args 'make',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/Users/Petersenrr/dev/qa-brightspot/node_modules/node-expat/build/config.gypi',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/usr/local/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/Users/Petersenrr/Library/Caches/node-gyp/16.4.1/include/node/common.gypi',
npm ERR! gyp info spawn args '-Dlibrary=shared_library',
npm ERR! gyp info spawn args '-Dvisibility=default',
npm ERR! gyp info spawn args '-Dnode_root_dir=/Users/Petersenrr/Library/Caches/node-gyp/16.4.1',
npm ERR! gyp info spawn args '-Dnode_gyp_dir=/usr/local/lib/node_modules/npm/node_modules/node-gyp',
npm ERR! gyp info spawn args '-Dnode_lib_file=/Users/Petersenrr/Library/Caches/node-gyp/16.4.1/<(target_arch)/node.lib',
npm ERR! gyp info spawn args '-Dmodule_root_dir=/Users/Petersenrr/dev/qa-brightspot/node_modules/node-expat',
npm ERR! gyp info spawn args '-Dnode_engine=v8',
npm ERR! gyp info spawn args '--depth=.',
npm ERR! gyp info spawn args '--no-parallel',
npm ERR! gyp info spawn args '--generator-output',
npm ERR! gyp info spawn args 'build',
npm ERR! gyp info spawn args '-Goutput_dir=.'
npm ERR! gyp info spawn args ]
npm ERR! gyp info spawn make
npm ERR! gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
npm ERR! env: python: No such file or directory
npm ERR! make: *** [Release/libexpat.a] Error 127
npm ERR! gyp ERR! build error
npm ERR! gyp ERR! stack Error: make failed with exit code: 2
npm ERR! gyp ERR! stack at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)
npm ERR! gyp ERR! stack at ChildProcess.emit (node:events:394:28)
npm ERR! gyp ERR! stack at Process.ChildProcess._handle.onexit (node:internal/child_process:290:12)
npm ERR! gyp ERR! System Darwin 21.5.0
npm ERR! gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
npm ERR! gyp ERR! cwd /Users/Petersenrr/dev/qa-brightspot/node_modules/node-expat
npm ERR! gyp ERR! node -v v16.4.1
npm ERR! gyp ERR! node-gyp -v v7.1.2
npm ERR! gyp ERR! not ok

NPM ERR!Một bản ghi hoàn chỉnh của chạy này có thể được tìm thấy trong: NPM ERR!/Users/peterSenrr
npm ERR! /Users/Petersenrr/.npm/_logs/2022-06-13T20_02_03_320Z-debug.log

Node Gyp có cần Python không?

Node-Gyp yêu cầu bạn đã cài đặt một phiên bản tương thích của Python, một trong: v3.7, v3.8, v3.9 hoặc v3.10.requires that you have installed a compatible version of Python, one of: v3.7, v3.8, v3.9, or v3.10.

Làm cách nào để cài đặt NPM?

Để cài đặt gói, NPM sử dụng thuật toán sau:..
Tải cây node_modules hiện có từ đĩa ..
nhân bản cây ..
Lấy gói.json và các loại siêu dữ liệu và thêm nó vào bản sao ..
Đi bộ bản sao và thêm bất kỳ sự phụ thuộc còn thiếu ..
Sự phụ thuộc sẽ được thêm vào gần với đầu càng tốt ..

Không thể tìm thấy Python thực thi Python Bạn có thể đặt biến Python Env trong macOS?

Dưới đây là một số bước bạn có thể thử ...
Cài đặt Python2.Bạn nên đảm bảo rằng trong thiết bị đầu cuối, mà -a python2 chỉ trả về một python2 và python2 -v trả về đúng 2. phiên bản x ..
Ghi đè Python Env.Xuất Python = Python2 ..
Chạy lại cài đặt ..