在 GitLab CI 中使用 Netlify-cli 部署时出错:找不到模块 netlify-cli/scripts/postinstall.js'
Error deploying with Netlify-cli in GitLab CI: Cannot find module netlify-cli/scripts/postinstall.js’
我正在尝试将我的 Gatsby 网站部署到 Netlify 作为我的 GitLab CI/CD 管道 的最后一步,我得到“Cannot find module netlify-cli/scripts/postinstall.js”部署过程中出错。
错误跟踪:
$ npx netlify-cli deploy --site $NETLIFY_SITE_ID --auth $NETLIFY_AUTH_TOKEN --prod
internal/modules/cjs/loader.js:1023
throw err;
^
Error: Cannot find module '/root/.npm/_npx/36/lib/node_modules/netlify-cli/scripts/postinstall.js'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:1020:15)
at Function.Module._load (internal/modules/cjs/loader.js:890:27)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
at internal/main/run_main_module.js:17:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
这是我的.gitlab-ci.yml配置:
image: node:latest
cache:
untracked: true
paths:
- node_modules/
stages:
- build
- deploy
build:
stage: build
script:
- npm install
- ./node_modules/.bin/gatsby build --prefix-paths
artifacts:
paths:
- public
only:
- merge_requests
- master
deploy:
stage: deploy
script:
- npm i -g netlify-cli
- npx netlify-cli deploy --site $NETLIFY_SITE_ID --auth $NETLIFY_AUTH_TOKEN --prod
dependencies:
- build
only:
- master
你知道怎么解决这个问题吗?
谢谢!
解决了,我是运行 "netlify-cli" 而不是"netlify":
有效:
npx netlify deploy --site $NETLIFY_SITE_ID --auth $NETLIFY_AUTH_TOKEN --prod
我正在尝试将我的 Gatsby 网站部署到 Netlify 作为我的 GitLab CI/CD 管道 的最后一步,我得到“Cannot find module netlify-cli/scripts/postinstall.js”部署过程中出错。
错误跟踪:
$ npx netlify-cli deploy --site $NETLIFY_SITE_ID --auth $NETLIFY_AUTH_TOKEN --prod
internal/modules/cjs/loader.js:1023
throw err;
^
Error: Cannot find module '/root/.npm/_npx/36/lib/node_modules/netlify-cli/scripts/postinstall.js'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:1020:15)
at Function.Module._load (internal/modules/cjs/loader.js:890:27)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
at internal/main/run_main_module.js:17:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
这是我的.gitlab-ci.yml配置:
image: node:latest
cache:
untracked: true
paths:
- node_modules/
stages:
- build
- deploy
build:
stage: build
script:
- npm install
- ./node_modules/.bin/gatsby build --prefix-paths
artifacts:
paths:
- public
only:
- merge_requests
- master
deploy:
stage: deploy
script:
- npm i -g netlify-cli
- npx netlify-cli deploy --site $NETLIFY_SITE_ID --auth $NETLIFY_AUTH_TOKEN --prod
dependencies:
- build
only:
- master
你知道怎么解决这个问题吗?
谢谢!
解决了,我是运行 "netlify-cli" 而不是"netlify":
有效:
npx netlify deploy --site $NETLIFY_SITE_ID --auth $NETLIFY_AUTH_TOKEN --prod