Tôi đã tạo một ứng dụng trên máy của mình và nó hoạt động tốt. Tôi đã tải lên nó vào máy chủ, và nó được đâm với các lỗi sau:node.js không thể tìm thấy mô-đun xml2js
node.js:116
throw e; // process.nextTick error, or 'error' event on first tick
^
Error: Cannot find module 'xml2js'
at Function._resolveFilename (module.js:289:11)
at Function._load (module.js:241:25)
at require (module.js:317:19)
at Object.<anonymous> (/var/www/node/price/index.js:3:14)
at Module._compile (module.js:373:26)
at Object..js (module.js:379:10)
at Module.load (module.js:305:31)
at Function._load (module.js:271:10)
at Array.<anonymous> (module.js:392:10)
at EventEmitter._tickCallback (node.js:108:26)
Đây là cách ứng dụng của tôi bắt đầu:
var express=require('express');
var http=require('http');
var xml2js = require('xml2js');
var sys = require('sys');
var util = require('util');
Tôi đã cài đặt cả hai nhanh và xml2js sử dụng NPM. Tôi có phiên bản chính xác giống nhau (v0.4.0) cho nút trên máy tính của tôi và máy chủ của tôi.
Tôi đã đảm bảo rằng đường dẫn trong đó xml2js và express cư trú (/ usr/local/lib/node /) được bao gồm trong các đường dẫn nơi nút tìm kiếm mô-đun. (Tôi đã chỉnh sửa tệp 'module.js' để in đường dẫn nơi tìm kiếm các mô-đun.)
node.js:116
throw e; // process.nextTick error, or 'error' event on first tick
^
Error: Cannot find module 'xml2js', in paths: /root/.node_modules,/root/.node_libraries,/usr/local/lib/node,/var/www/node/price/node_modules,/var/www/node/node_modules,/var/www/node_modules,/var/node_modules,/node_modules
at Function._resolveFilename (module.js:289:11)
at Function._load (module.js:241:25)
at require (module.js:317:19)
at Object.<anonymous> (/var/www/node/price/index.js:3:14)
at Module._compile (module.js:373:26)
at Object..js (module.js:379:10)
at Module.load (module.js:305:31)
at Function._load (module.js:271:10)
at Array.<anonymous> (module.js:392:10)
at EventEmitter._tickCallback (node.js:108:26)
Vì vậy, có gì sai? Tôi có đường dẫn đúng, mô-đun ở đó. Tại sao nút không thể tìm thấy? Và chính xác cùng một mã chạy trơn tru trên máy địa phương của tôi. Nếu nó quan trọng, máy của tôi là một máy Mac, và máy chủ chạy CentOS.
Có thể có liên quan: http://groups.google.com/group/nodejs/browse_thread/thread/61d6cf86f1593e10 –