在github动作中安装npm模块 [英] install npm modules in github actions

查看:67
本文介绍了在github动作中安装npm模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个脚本,该脚本应该在每个主部署上创建一个站点地图

I have this script that is supposed to create a sitemap on each master deployment

name: create-map
on: push

jobs:
  run_tests:
    runs-on: ubuntu-20.04
    steps:
    - uses: actions/checkout@v2
    - uses: actions/setup-node@v2
      with:
        node-version: '12'
        check-latest: true
    - name: Run script file
      run: |
      
         chmod +x ./scripts/createmap.sh
         ./scripts/createmap.sh
      shell: bash

createmap.sh 脚本类似于

cd public
rm -rf sitemap
mkdir sitemap
cd ..
cd scripts
node ./sitemap-posts.js
node ./compress-map.js
node ./create-one-map.js

curl http://google.com/ping?sitemap=https://website.com/sitemap.xml

上方的三个脚本,例如sitemap-posts 位于我网站的根目录中的 scripts 文件夹中.它们在每个文件的顶部都有模块,例如

The three scripts above eg. sitemap-posts are located in the root folder of my website in scripts folder. They have modules at the top of each file like

const fs = require("fs");
const globby = require("globby");
const prettier = require("prettier");
const firebase = require("firebase");

完成部署后,发生错误错误:找不到模块'更漂亮'错误:找不到模块'globby'.我对此很陌生,我认为这些模块将从我的网站 package.json 文件中获取.

When a deployment is done an error occurs Error: Cannot find module 'prettier' and Error: Cannot find module 'globby'. I am fairly new to this and i thought these modules would be fetched from my website package.json file.

如何解决这些错误

推荐答案

在执行 createmap.sh 中的脚本之前,您似乎没有运行 npm install .

It looks like you didn't run npm install before executing the scripts in createmap.sh.

还请注意, node_modules 目录必须是sitemap-posts.js,compress-map.js和create-one-map.js的同级

Please also note that the node_modules directory have to be a sibling of sitemap-posts.js, compress-map.js and create-one-map.js

这篇关于在github动作中安装npm模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆