Ошибка: не удается найти модуль «xml2json»

Когда я запускаю пакет моего проекта, я получаю сообщение об ошибке выше заголовка после того, как пытаюсь установить эти пакеты, используя

npm установить xml2json

но я получаю только ошибку ниже, не могли бы вы дать мне предложения или идеи, чтобы выйти из этой проблемы...

D:\xampp\htdocs\podio>npm install xml2json

> [email protected] install D:\xampp\htdocs\podio\node_modules\node-expat
> node-gyp rebuild


D:\xampp\htdocs\podio\node_modules\node-expat>if not defined npm_config_node_gyp
 (node "C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin\\..\..\node_mo
dules\node-gyp\bin\node-gyp.js" rebuild )  else (node "" rebuild )
Warning: Missing input files:
D:\xampp\htdocs\podio\node_modules\node-expat\build\deps\libexpat\..\..\..\deps\
libexpat\version.c
Building the projects in this solution one at a time. To enable parallel build,
please add the "/m" switch.
MSBUILD : error MSB3428: Could not load the Visual C++ component "VCBuild.exe".
 To fix this, 1) install the .NET Framework 2.0 SDK, 2) install Microsoft Visua
l Studio 2005 or 3) add the location of the component to the system path if it
is installed elsewhere.  [D:\xampp\htdocs\podio\node_modules\node-expat\build\b
inding.sln]
gyp ERR! build error
gyp ERR! stack Error: `C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe
` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onExit (C:\Program Files\nodejs\node_modules\
npm\node_modules\node-gyp\lib\build.js:276:23)
gyp ERR! stack     at emitTwo (events.js:106:13)
gyp ERR! stack     at ChildProcess.emit (events.js:191:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_proces
s.js:219:12)
gyp ERR! System Windows_NT 6.3.9600
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodej
s\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd D:\xampp\htdocs\podio\node_modules\node-expat
gyp ERR! node -v v6.11.5
gyp ERR! node-gyp -v v3.4.0
gyp ERR! not ok
npm ERR! Windows_NT 6.3.9600
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\
node_modules\\npm\\bin\\npm-cli.js" "install" "xml2json"
npm ERR! node v6.11.5
npm ERR! npm  v3.10.10
npm ERR! code ELIFECYCLE

npm ERR! [email protected] install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script 'node-gyp rebuild'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the node-expat package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-gyp rebuild
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs node-expat
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls node-expat
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     D:\xampp\htdocs\podio\npm-debug.log

Изменить :: 1

После того, как я установил обновленную визуальную студию с 2005 по 2012 год, я получаю сообщение об ошибке ниже, когда я запускаю npm install xml2json и npm install xml2json --unsafe-perm,

C:\Users\Desktop\New folder\action>npm install xml2json

> [email protected] install C:\Users\Hoffensoft\node_modules\node-expat
> node-gyp rebuild


C:\Users\Hoffensoft\node_modules\node-expat>if not defined npm_config_node_gyp (
node "C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin\\..\..\node_modu
les\node-gyp\bin\node-gyp.js" rebuild )  else (node "" rebuild )
Warning: Missing input files:
C:\Users\Hoffensoft\node_modules\node-expat\build\deps\libexpat\..\..\..\deps\li
bexpat\version.c
Building the projects in this solution one at a time. To enable parallel build,
please add the "/m" switch.
  xmlparse.c
  xmltok.c
  xmlrole.c
c:\users\hoffensoft\node_modules\node-expat\deps\libexpat\lib\siphash.h(201): w
arning C4244: 'initializing' : conversion from '__int64' to 'char', possible lo
ss of data (..\..\..\deps\libexpat\lib\xmlparse.c) [C:\Users\Hoffensoft\node_mo
dules\node-expat\build\deps\libexpat\expat.vcxproj]
  win_delay_load_hook.cc
  expat.vcxproj -> C:\Users\Hoffensoft\node_modules\node-expat\build\Release\\l
  ibexpat.lib
  node-expat.cc
  win_delay_load_hook.cc
C:\Users\Hoffensoft\node_modules\nan\nan.h(75): fatal error C1060: compiler is
out of heap space (..\node-expat.cc) [C:\Users\Hoffensoft\node_modules\node-exp
at\build\node_expat.vcxproj]
gyp ERR! build error
gyp ERR! stack Error: `C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe
` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onExit (C:\Program Files\nodejs\node_modules\
npm\node_modules\node-gyp\lib\build.js:276:23)
gyp ERR! stack     at emitTwo (events.js:106:13)
gyp ERR! stack     at ChildProcess.emit (events.js:191:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_proces
s.js:219:12)
gyp ERR! System Windows_NT 6.3.9600
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodej
s\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd C:\Users\Hoffensoft\node_modules\node-expat
gyp ERR! node -v v6.11.5
gyp ERR! node-gyp -v v3.4.0
gyp ERR! not ok
npm WARN enoent ENOENT: no such file or directory, open 'C:\Users\Hoffensoft\pac
kage.json'
npm WARN Hoffensoft No description
npm WARN Hoffensoft No repository field.
npm WARN Hoffensoft No README data
npm WARN Hoffensoft No license field.
npm ERR! Windows_NT 6.3.9600
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\
node_modules\\npm\\bin\\npm-cli.js" "install" "xml2json"
npm ERR! node v6.11.5
npm ERR! npm  v3.10.10
npm ERR! code ELIFECYCLE

npm ERR! [email protected] install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script 'node-gyp rebuild'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the node-expat package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-gyp rebuild
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs node-expat
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls node-expat
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     C:\Users\Hoffensoft\Desktop\New folder\action\npm-debug.log

Заранее спасибо, Гопал Р.


person RGKrish183    schedule 20.03.2018    source источник
comment
В сообщении об ошибке, начиная со строки «Чтобы это исправить, 1) установить...», написано предложение. Вы пробовали эти предложения?   -  person Arpit Solanki    schedule 20.03.2018
comment
Сделайте npm install xml2json --save   -  person Mohammad Raheem    schedule 20.03.2018
comment
да @ArpitSolanki, я попробовал, я установил, но все еще не работает   -  person RGKrish183    schedule 20.03.2018
comment
Нет @MohammadRaheem, который также получает только ту же ошибку, --save просто сохраняет имя в файле package.json   -  person RGKrish183    schedule 20.03.2018
comment
Вы используете Angular 2/4?   -  person Darshan Vachhani    schedule 20.03.2018
comment
Нет, @D.V, это своего рода промежуточное программное обеспечение.   -  person RGKrish183    schedule 20.03.2018
comment
Удалите каталог node modules, очистите npm-cache с помощью команды npm cache clean --force, а затем попробуйте установить тот же пакет, выполнив команду npm install xml2json --unsafe-perm, и если он сломается при той же зависимости, используйте команду npm install [email protected] --unsafe-perm.   -  person Suhas Gavad    schedule 20.03.2018
comment
Нет, приятель @SuhasGavad, все еще получаю ту же ошибку, не повезло...   -  person RGKrish183    schedule 21.03.2018
comment
Что выводит команда npm config get registry?   -  person Suhas Gavad    schedule 21.03.2018
comment
@SuhasGavad, D:\xampp\htdocs\podio›npm config получить реестр registry.npmjs.org   -  person RGKrish183    schedule 21.03.2018
comment
Вы можете попробовать эту команду npm install [email protected] --unsafe-perm. если он успешно установлен, снова попробуйте установить пакет xml2json. и было бы здорово, если бы вы переключились на последнюю версию node и npm.   -  person Suhas Gavad    schedule 21.03.2018
comment
@SuhasGavad, нет, я пробовал то, что было сказано ранее, я получил только ту же ошибку   -  person RGKrish183    schedule 21.03.2018
comment
проверьте результат команды curl registry.npmjs.org. чтобы убедиться, что сеть не блокирует ваш вызов запроса.   -  person Suhas Gavad    schedule 21.03.2018
comment
Я решил это здесь: stackoverflow.com/a/55093298/2958314 (дополнительные десять символов для ограничения количества сообщений).   -  person Uncle Gus    schedule 11.03.2019


Ответы (2)


Я решил эту проблему
Используйте эту команду npm install xml2json-light
и измените let parser = require('xml2json'); на let parser = require('xml2json-light');
Это сработало для меня

person Kunal Tyagi    schedule 29.08.2019

Я решил это. Если вы заметили эту часть команды else (node "" rebuild ), я думаю, что происходит то, что она неправильно оценивает if not defined npm_config_node_gyp как false и пытается ничего не запускать вместо node-gyp. Что вам нужно сделать, так это определить переменную npm_config_node_gyp. Вы можете сделать это так: export npm_config_node_gyp=<PATH_TO_NODE_GYP_PACKAGE_FOLDER> помните, что для Windows потребуется двойная обратная косая черта. У меня это выглядело так: export npm_config_node_gyp=C:\\Users\\781990\\AppData\\Roaming\\nvm\\v6.11.0\\node_modules\\node-gyp

Изменить: после моего исправления есть еще один шаг. При выполнении моего кода привязки expat отсутствовали. Чтобы исправить это, добавьте папку bin и исполняемый файл node-gyp в переменную npm_config_node_gyp и запустите node-gyp rebuild в папке node_modules\node-expat. например export npm_config_node_gyp=C:\\Users\\781990\\AppData\\Roaming\\nvm\\v6.11.0\\node_modules\\node-gyp\\bin\\node-gyp.js cd node_modules\node-expat node-gyp rebuild

person Uncle Gus    schedule 11.03.2019