strapi安装

A_Ghost -
strapi安装
1,安装

执行如下命令,进行安装。

yarn create strapi-app my-project --quickstart

如果没有安装 yarn
npm install -g yarn
如果依旧报错:‘yarn’ 不是内部或外部命令,也不是可运行的程序将yarn 添加到系统的环境变量里面。
如果出现:You need to install the latest version of Visual Studio

gyp ERR! find VS
gyp ERR! find VS **************************************************************
gyp ERR! find VS You need to install the latest version of Visual Studio
gyp ERR! find VS including the  "Desktop development with C++" workload.
gyp ERR! find VS For more information consult the documentation at:
gyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows

以管理员身份打开cmd,执行命令

npm install reinstall -g
npm install -g windows-build-tools

安装之后将重新执行 yarn create strapi-app my-project --quickstart ,在此之前要先将my-project 文件删除。

2,基本配置

2.1,安装完成之后,会自动打开 http://localhost:1337/admin/a...,注册账号密码。注意,密码包含大小写,邮箱是随便写的:ghost@test.com
2.2,进入文件config / database配置 数据库

module.exports = ({ env }) => ({
  defaultConnection: 'default',
  connections: {
    default: {
      connector: 'bookshelf',
      settings: {
        client: 'postgres',
        host: 'localhost',
        port: '5432',
        database: 'postgres',
        username: 'postgres',
        password: 'root',
        // filename: env('DATABASE_FILENAME', '.tmp/data.db'),
      },
      options: {
        useNullAsDefault: true,
      },
    },
  },
});

保存,重新启动,结果报错了:The client pg is not installed.
执行:npm install pg --save,再重新启动,项目起来了 。

3,使用

进入页面,http://localhost:1337/admin,点击内容类型生成器 Content Type
3.1,填写显示名称,即数据库的表名。
3.2,填写字段名,定义类型,也可以设置默认值。
3.3,在api/ test/config/routes.json 里就会有6个接口,增删改查。
3.4,配置用户权限。 设置——角色和权限——public——APPLICATION 的增删改查都加上。

特别申明:本文内容来源网络,版权归原作者所有,如有侵权请立即与我们联系(cy198701067573@163.com),我们将及时处理。

Tags 标签

node.js

扩展阅读

加个好友,技术交流

1628738909466805.jpg