[nspady/google-calendar-mcp] windows환경에서 npm install 안 되는 문제

짱발자·2025년 5월 1일
0

Error

목록 보기
4/4
post-thumbnail

문제 상황

google calendar mcp 서버 중 가장 스타도 많고 컨트리뷰터도 많은
https://github.com/nspady/google-calendar-mcp 를 가지고 구축하려고 했다.

근데 npm install을 하면 자꾸만 오류가 나는 것임.

$ npm install

> google-calendar-mcp@1.1.0 postinstall
> scripts/build.js

'scripts'() 내부 또는 외부 명령, 실행할 수 있는 프로그램, 또는
배치 파일이 아닙니다.
npm error code 1
npm error path C:\Users\...\google-calendar-mcp
npm error command failed
npm error command C:\WINDOWS\system32\cmd.exe /d /s /c scripts/build.js  
npm error A complete log of this run can be found in: C:\Users\ooo\AppData\Local\npm-cache\_logs\2025-05-01T03_02_37_553Z-debug-0.log

계속해서 이런 오류가 났다.

접근

1. node 버전때문인가?

먼저 README에 Node를 LTS 버전을 사용하라고 나와있었기에, v22.15.0을 사용하였고, npm도 11.x.x의 최신 버전을 사용하였다.

그런데 scripts/build.js를 보면

#!/usr/bin/env node

import * as esbuild from 'esbuild';
import { fileURLToPath } from 'url';
import { dirname, join } from 'path';

const __dirname = dirname(fileURLToPath(import.meta.url));
const isWatch = process.argv.includes('--watch');

/** @type {import('esbuild').BuildOptions} */
const buildOptions = {
  entryPoints: [join(__dirname, '../src/index.ts')],
  bundle: true,
  platform: 'node',
  target: 'node18', /////////////////⬅️이 부분과
  outfile: join(__dirname, '../build/index.js'),
  format: 'esm',
  banner: {
    js: '#!/usr/bin/env node\n',
  },
  packages: 'external', // Don't bundle node_modules
  sourcemap: true,
};

/** @type {import('esbuild').BuildOptions} */
const authServerBuildOptions = {
  entryPoints: [join(__dirname, '../src/auth-server.ts')],
  bundle: true,
  platform: 'node',
  target: 'node18', /////////////////⬅️이 부분
  outfile: join(__dirname, '../build/auth-server.js'),
  format: 'esm',
  packages: 'external', // Don't bundle node_modules
  sourcemap: true,
};

if (isWatch) {
  const context = await esbuild.context(buildOptions);
  const authContext = await esbuild.context(authServerBuildOptions);
  await Promise.all([context.watch(), authContext.watch()]);
  console.log('Watching for changes...');
} else {
  await Promise.all([
    esbuild.build(buildOptions),
    esbuild.build(authServerBuildOptions)
  ]);
  
  // Make the file executable on non-Windows platforms
  if (process.platform !== 'win32') {
    const { chmod } = await import('fs/promises');
    await chmod(buildOptions.outfile, 0o755);
  }
} 

node18이라고 되어 있길래 뭘 의미하는지 잘 모르지만 맞춰줘야 할 것 같아서 nvm 깔고 버전을 바꿨다. 근데도 안 돌아 갔다..

2. package.json 확인

{
    "name": "google-calendar-mcp",
    "version": "1.1.0",
    "description": "Google Calendar MCP Server",
    "type": "module",
    "bin": {
        "google-calendar-mcp": "./build/index.js"
    },
    "scripts": {
        "typecheck": "tsc --noEmit",
        "build": "npm run typecheck && node scripts/build.js", 
        "start": "node build/index.js",
        "auth": "node build/auth-server.js",
        "postinstall": "scripts/build.js", //////////⬅️이 부분
        "test": "vitest run",
        "test:watch": "vitest",
        "coverage": "vitest run --coverage"
    },
    "dependencies": {
        "@google-cloud/local-auth": "^3.0.1",
        "@modelcontextprotocol/sdk": "^1.0.3",
        "@types/express": "^4.17.21",
        "esbuild": "^0.25.3",
        "express": "^4.18.2",
        "google-auth-library": "^9.15.0",
        "googleapis": "^144.0.0",
        "open": "^7.4.2",
        "zod": "^3.22.4"
    },
    "devDependencies": {
        "@types/node": "^20.10.4",
        "@vitest/coverage-v8": "^3.1.1",
        "typescript": "^5.8.3",
        "vitest": "^3.1.1"
    }
}

windows 환경에서는 그냥 scripts/build.js 를 실행할 수가 없는 것..!!!
node 를 앞에 붙여줘야 한다...

해결

별 짓 다 해봤지만 결국 node 명령어 하나 빠져서 이렇게 된 것.

"postinstall": "scripts/build.js"

⬇️

"postinstall": "node scripts/build.js"

node 넣어줘서 해결!


+++ node 버전은 문제가 아니었음 nvm으로 22.15.0버전으로 바꿔서 했음에도 잘 돌아감.

profile
안 되는 게 어딨어🎵 전부 해보면 되지🎵 디버깅 되고 되고 되고🎵

0개의 댓글