Tôi có một ứng dụng JS. Nó hoạt động tốt trên linux nhưng trong windows 10 tôi nhận được một lỗi.Lỗi: spawn npm ENOENT
events.js:161
throw er; // Unhandled 'error' event
^
Error: spawn npm ENOENT
at exports._errnoException (util.js:1028:11)
at Process.ChildProcess._handle.onexit (internal/child_process.js:193:32)
at onErrorNT (internal/child_process.js:359:16)
at _combinedTickCallback (internal/process/next_tick.js:74:11)
at process._tickCallback (internal/process/next_tick.js:98:9)
at Module.runMain (module.js:607:11)
at run (bootstrap_node.js:422:7)
at startup (bootstrap_node.js:143:9)
at bootstrap_node.js:537:3
và mã đó là không chính xác là thế này
const spawn = require('child_process').spawn;
const watching = [
// {service: "babel-watch"},
{service: "webpack-watch"},
// {service: "sass-watch"},
{service: "server-watch"}
];
watching.forEach(({service}) => {
const child = spawn('npm', ['run', service]);
child.stdout.on('data', d => console.log(d.toString()));
child.stderr.on('data', d => console.log(d.toString()));
});
Tôi thấy lý do của lỗi này trong github Tôi đoán vấn đề đang đẻ trứng nodejs spawn Doc có đã không làm việc một cách chính xác trong các cửa sổ. Nhưng tôi không biết làm thế nào để sửa đổi đoạn mã này để làm cho nó hoạt động. Ai đó có thể giúp tôi ?
Hãy thử gợi ý ở đây : http://stackoverflow.com/questions/27688804/how-do-i-debug-error-spawn-enoent-on-node-js và tại đây: http://stackoverflow.com/questions/34208614/how-to -catch-an-enoent-với-nodejs-child-process-đẻ trứng để có thêm inf o về lỗi – Strelok
Phiên bản NodeJS nào bạn đang sử dụng? –
@PramodPatil v7.6.0 –