Skip to content

安装依赖报 spawn npm ENOENT 错误 #1

Description

@chenmonster

执行 gitbook-installspawn npm ENOENT 错误
原因:在windows下npm的执行命令不同1

将 gitbook-install/lib/util.js 文件中第53行代码修改如下

  installPlugins() {
    if(plugins === null) throw new Error('Error: no plugins');
    if(args    === null) throw new Error('Error: no npm arguments');

-   cp.execFile('npm', args, (err, stdout) => {
+   cp.execFile(process.platform === 'win32' ? 'npm.cmd' : 'npm', args, (err, stdout) => {
      if(err) {
        throw(err);
      } else {
        log();
        log(stdout);
        process.exit();
      }
    });

    return this;
  },

Footnotes

  1. spawn npm ENOENT解决方法

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions