相关疑难解决方法(0)

如何在每次Gulpfile更改后重新启动Gulp?

我正在开发一个Gulpfile.一旦它改变就可以重新启动吗?我正在用CoffeeScript开发它.可以Gulp观看Gulpfile.coffee以便在保存更改时重新启动?

javascript workflow node.js gulp gulp-watch

65
推荐指数
4
解决办法
2万
查看次数

使用带有NODE_ENV = production的spawn函数

我目前正在尝试使用spawn.我试图从shell运行的是以下内容;

NODE_ENV=production node app/app.js

这是运行它的代码;

var spawn = require('child_process').spawn;
var start = spawn('NODE_ENV=production',['node','app/app.js']);
Run Code Online (Sandbox Code Playgroud)

但是,我收到了以下错误;

events.js:72
        throw er; // Unhandled 'error' event
              ^
Error: spawn ENOENT
    at errnoException (child_process.js:980:11)
    at Process.ChildProcess._handle.onexit (child_process.js:771:34)
Run Code Online (Sandbox Code Playgroud)

我该怎么做spawn呢?

node.js

29
推荐指数
3
解决办法
2万
查看次数

错误:产生npm ENOENT

我有一个JS应用程序.它在linux上运行良好但在Windows 10中我收到错误.

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
Run Code Online (Sandbox Code Playgroud)

并且不正确的代码就是这个

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()));
});
Run Code Online (Sandbox Code Playgroud)

我在github中 …

javascript windows node.js

15
推荐指数
2
解决办法
1万
查看次数

Rust(VSCode)错误:spawnSync undefined ENOENT

我收到这个错误:

错误:spawnSync未定义ENOENT

总是,当我在VSCode中保存文件时,但结果证明编译正常.

我怎么能解决这个问题?

我读到这个: 如何在node.js上调试"Error:spawn ENOENT"? 但我不知道这是否相关.

rust visual-studio-code

11
推荐指数
1
解决办法
2876
查看次数

产生ENOENT错误

我正在尝试使用成像器模块将内容上传到amazon s3.我一直收到错误信息,说

events.js:72
    throw er; // Unhandled 'error' event
              ^
Error: spawn ENOENT
    at errnoException (child_process.js:980:11)
    at Process.ChildProcess._handle.onexit (child_process.js:771:34)
Run Code Online (Sandbox Code Playgroud)

我已经在我的计算机上安装了imagemagick,但它一直说它没有关联,这可能是问题吗?我也尝试使用brew链接imagemagick进行链接,但由于某种原因无法链接.我正在使用OSx.任何修复?

谢谢.

error-handling imagemagick image-uploading node.js

10
推荐指数
1
解决办法
1万
查看次数

如何使用nodejs child_process.spawn捕获ENOENT?

我正在使用spawn生成一个长时间运行的进程,该进程将输出随时间发送到stdio,并由我的nodejs脚本读取和处理.棘手的部分是我无法保证发送的命令始终有效.如何在产卵时发现错误?最好这不涉及安装全局异常处理程序,因为我不想处理任何其他异常.(如果这是唯一的方法,我需要弄清楚生成的进程何时正确启动然后卸载处理程序,这是一个混乱,我宁愿不进入.)

我想要运行的代码是这样的:

var spawn = require('child_process').spawn;

try {
    spawn("zargle");
} catch (e) {
    console.error("I'm handling the error!");
}
Run Code Online (Sandbox Code Playgroud)

但这只会在节点事件循环中的某处产生一个uncaughtException,大概是因为调用是异步的,甚至没有尝试在我的脚本的时间片上启动子进程.

需要捕获的唯一异常是当spawn完全无法启动进程时(例如,名称不正确并且抛出ENOENT).我(此时)并不关心衍生过程可能产生的任何问题.


类似但不同:如何在node.js上调试"错误:生成ENOENT"?

我确切地知道为什么我会获得ENOENT,而且我知道要改变什么以避免错误发生.我的问题是如果错误是不可避免的,如何优雅地回应这种情况.

child-process node.js

10
推荐指数
2
解决办法
1万
查看次数

Grunt任务中的节点JS - child_process spawn('npm install')导致ENOENT错误

我正在创作一个Grunt任务有些困难.我正在尝试执行npm install,然后执行bower install,然后执行grunt hub目标(触发多个子项目的构建命令).

我遇到的问题在于child_process.如果我在我的grunt任务中运行以下命令,并且当前已注释掉的npm install spawn命令,则会出现生成ENOENT错误:

    var path = require('path'),
        projectPath = path.resolve(process.cwd(), this.data.activity );

        grunt.log.debug('project path computed as: ', projectPath);
        process.chdir( projectPath );

        console.log('current dir is: ', process.cwd());
        console.log('EVN is: ', process.env);

        var spawnProcess = spawn('ls');
        // var spawnProcess = spawn('npm install');

        spawnProcess.stdout.on('data', function (data) {
            console.log('' + data);
        });

        spawnProcess.stderr.on('data', function(data) {

            console.log('something went wrong installing deps for ' + path + '.  Error: ', data);
        });

        spawnProcess.on('close', function (exitCode) {

            console.log( 'ls has finished with Exit …
Run Code Online (Sandbox Code Playgroud)

node.js npm gruntjs

8
推荐指数
1
解决办法
7580
查看次数

使用子进程 NodeJS 运行 exe 文件

我想用 nodejs 打开谷歌浏览器,但出现此错误(我使用了 execFile 和 spawn),

代码

var execFile = require('child_process').execFile,
spawn = require('child_process').spawn,

spawn('C\\Program Files\\Google\\Chrome\\Application\\chrome.exe', function (error, stdout, stderr) {
   if (error !== null) { console.log('exec error: ' + error); }
});

events.js:72
    throw er; // Unhandled 'error' event
          ^
Error: spawn ENOENT
at errnoException (child_process.js:998:11)
at Process.ChildProcess._handle.onexit (child_process.js:789:34)
Run Code Online (Sandbox Code Playgroud)

windows child-process node.js

7
推荐指数
1
解决办法
9823
查看次数

将文件从目录拉入NPM的根文件夹

我正在向NPM出版一个图书馆.

当我构建库时,生成的工件将放置在dist项目根目录中的文件夹中index.js.

当用户从NPM安装时,我希望index.js出现在其文件夹中创建的文件夹的node_modules目录中.目前,它仍保留在一个名为的目录中dist.

我怎样才能做到这一点?

我的packages.json:

{
  "name": "my-package",
  "version": "0.0.9",
  "files": ["dist/*"],
  "main": "index.min.js",
  "private": false,
  "dependencies": {},
  "devDependencies": {},
  "repository": "git@github.com:username/my-package.git"
}
Run Code Online (Sandbox Code Playgroud)

npm

7
推荐指数
1
解决办法
770
查看次数

产生ENOENT node.js错误

我已经使用快速生成器启动了一个node.js应用程序,我有一个奇怪的问题,我无法通过浏览器两次查看页面,第一次加载正常,第二次没有因为节点进程结束以下错误:

GET / 304 412ms

events.js:72
        throw er; // Unhandled 'error' event
              ^
Error: spawn ENOENT
    at errnoException (child_process.js:988:11)
    at Process.ChildProcess._handle.onexit (child_process.js:779:34)
Run Code Online (Sandbox Code Playgroud)

的package.json

{
  "name": "example01-express",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "node-dev ./bin/www"
  },
  "dependencies": {
    "body-parser": "~1.0.0",
    "cookie-parser": "~1.0.1",
    "debug": "~0.7.4",
    "express": "~4.2.0",
    "jade": "~1.3.0",
    "morgan": "~1.0.0",
    "node-compass": "0.2.3",
    "static-favicon": "~1.0.0"
  },
  "devDependencies": {
    "grunt": "^0.4.5",
    "grunt-contrib-cssmin": "*",
    "grunt-contrib-jshint": "^0.10.0",
    "grunt-contrib-sass": "*",
    "grunt-contrib-uglify": "*",
    "grunt-contrib-watch": "*",
    "grunt-cssc": "*",
    "grunt-htmlhint": "*",
    "matchdep": "*"
  }
}
Run Code Online (Sandbox Code Playgroud)

javascript node.js express express-generator

6
推荐指数
1
解决办法
1万
查看次数