i am newbie to nodejs. Để kết nối mysql, tôi đã cài đặt mysql
trên nút bằng cách sử dụng lệnh,Không thể tìm thấy mô-đun `mysql` node.js
npm install mysql
Tôi không gặp lỗi trong khi cài đặt. Sau đó, tôi đã thử thực thi đoạn mã sau,
var mysql = require("mysql");
Nhưng nó hiển thị lỗi sau trong khi im cố gắng thực hiện điều đó.
C:\node\mysql>node app.js
module.js:340
throw err;
^
Error: Cannot find module 'mysql'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (C:\node\mysql\app.js:1:75)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
tôi đã cố gắng một số gợi ý như cài đặt mysql trên toàn cầu sử dụng,
npm install -g mysql
Nhưng không có gì làm việc. Giúp xin vui lòng !!!
Xin lưu ý môi trường làm việc của tôi,
OS: Windows7 Node phiên bản: 0.10.15 NPM phiên bản: 1.3.5
Bạn có đang chạy tập lệnh của mình từ cùng thư mục mà bạn đã chạy 'npm install mysql' không? –
Ngoài ra, sử dụng 'npm install -g' là cài đặt chung. –
@MorganARRAllen Cảm ơn. sửa chữa. :) – Stranger