错误“\"node .\bin\www\"”未被识别为内部或外部命令、可运行的程序或带有 gulp 的批处理文件
Error '\"node .\bin\www\"' is not recognized as an internal or external command, operable program or batch file with gulp
您好,我正在使用 gulp
和 nodemon
实用程序来自动化我的构建过程。在我使用 vscode 手动调试我的应用程序之前,它一直在工作。我现在不想调试它,想运行它简单。
我正在运行使用此命令启动gulp 并在 JS 文件发生任何更改时自动构建,但出现错误。
我检查了一些建议使用 set DEBUG=express:* & node bin/www
的线程,它正在运行。我不想这样做,不知道它有什么作用。我想使用 gulp
.
$ gulp
[18:11:31] Using gulpfile D:\api\gulpfile.js
[18:11:31] Starting 'default'...
[18:11:31] Finished 'default' after 101 ms
[18:11:31] [nodemon] 1.12.0
[18:11:31] [nodemon] to restart at any time, enter `rs`
[18:11:31] [nodemon] watching: *.*
[18:11:31] [nodemon] starting `node ./bin/www`
'\"node .\bin\www\"' is not recognized as an internal or external command,
operable program or batch file.
[18:11:31] [nodemon] app crashed - waiting for file changes before starting...
gulpfile.js
const gulp = require("gulp"),
nodemon = require("gulp-nodemon");
gulp.task("default", () => {
nodemon({ ext: "js" });
});
www
#!/usr/bin/env node
/**
* Module dependencies.
*/
var app = require('../app');
var debug = require('debug')('cryptocurrency-api:server');
var http = require('http');
/**
* Get port from environment and store in Express.
*/
var port = normalizePort(process.env.PORT || '3000');
app.set('port', port);
/**
* Create HTTP server.
*/
var server = http.createServer(app);
/**
* Listen on provided port, on all network interfaces.
*/
server.listen(port);
server.on('error', onError);
server.on('listening', onListening);
/**
* Normalize a port into a number, string, or false.
*/
function normalizePort(val) {
var port = parseInt(val, 10);
if (isNaN(port)) {
// named pipe
return val;
}
if (port >= 0) {
// port number
return port;
}
return false;
}
/**
* Event listener for HTTP server "error" event.
*/
function onError(error) {
if (error.syscall !== 'listen') {
throw error;
}
var bind = typeof port === 'string'
? 'Pipe ' + port
: 'Port ' + port;
// handle specific listen errors with friendly messages
switch (error.code) {
case 'EACCES':
console.error(bind + ' requires elevated privileges');
process.exit(1);
break;
case 'EADDRINUSE':
console.error(bind + ' is already in use');
process.exit(1);
break;
default:
throw error;
}
}
/**
* Event listener for HTTP server "listening" event.
*/
function onListening() {
var addr = server.address();
var bind = typeof addr === 'string'
? 'pipe ' + addr
: 'port ' + addr.port;
debug('Listening on ' + bind);
}
nodemon 版本 1.12.0 可能损坏了某些内容。
有同样的问题并通过删除并重新安装旧版本解决了它。
删除 nodemon 使用:
yarn global remove nodemon
然后重新安装 - 这次指定旧版本
yarn global install nodemon@1.11.0
您好,我正在使用 gulp
和 nodemon
实用程序来自动化我的构建过程。在我使用 vscode 手动调试我的应用程序之前,它一直在工作。我现在不想调试它,想运行它简单。
我正在运行使用此命令启动gulp 并在 JS 文件发生任何更改时自动构建,但出现错误。
我检查了一些建议使用 set DEBUG=express:* & node bin/www
的线程,它正在运行。我不想这样做,不知道它有什么作用。我想使用 gulp
.
$ gulp
[18:11:31] Using gulpfile D:\api\gulpfile.js
[18:11:31] Starting 'default'...
[18:11:31] Finished 'default' after 101 ms
[18:11:31] [nodemon] 1.12.0
[18:11:31] [nodemon] to restart at any time, enter `rs`
[18:11:31] [nodemon] watching: *.*
[18:11:31] [nodemon] starting `node ./bin/www`
'\"node .\bin\www\"' is not recognized as an internal or external command,
operable program or batch file.
[18:11:31] [nodemon] app crashed - waiting for file changes before starting...
gulpfile.js
const gulp = require("gulp"),
nodemon = require("gulp-nodemon");
gulp.task("default", () => {
nodemon({ ext: "js" });
});
www
#!/usr/bin/env node
/**
* Module dependencies.
*/
var app = require('../app');
var debug = require('debug')('cryptocurrency-api:server');
var http = require('http');
/**
* Get port from environment and store in Express.
*/
var port = normalizePort(process.env.PORT || '3000');
app.set('port', port);
/**
* Create HTTP server.
*/
var server = http.createServer(app);
/**
* Listen on provided port, on all network interfaces.
*/
server.listen(port);
server.on('error', onError);
server.on('listening', onListening);
/**
* Normalize a port into a number, string, or false.
*/
function normalizePort(val) {
var port = parseInt(val, 10);
if (isNaN(port)) {
// named pipe
return val;
}
if (port >= 0) {
// port number
return port;
}
return false;
}
/**
* Event listener for HTTP server "error" event.
*/
function onError(error) {
if (error.syscall !== 'listen') {
throw error;
}
var bind = typeof port === 'string'
? 'Pipe ' + port
: 'Port ' + port;
// handle specific listen errors with friendly messages
switch (error.code) {
case 'EACCES':
console.error(bind + ' requires elevated privileges');
process.exit(1);
break;
case 'EADDRINUSE':
console.error(bind + ' is already in use');
process.exit(1);
break;
default:
throw error;
}
}
/**
* Event listener for HTTP server "listening" event.
*/
function onListening() {
var addr = server.address();
var bind = typeof addr === 'string'
? 'pipe ' + addr
: 'port ' + addr.port;
debug('Listening on ' + bind);
}
nodemon 版本 1.12.0 可能损坏了某些内容。
有同样的问题并通过删除并重新安装旧版本解决了它。
删除 nodemon 使用:
yarn global remove nodemon
然后重新安装 - 这次指定旧版本
yarn global install nodemon@1.11.0