关于node.js:strapi安装

5次阅读

共计 1350 个字符,预计需要花费 4 分钟才能阅读完成。

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 的增删改查都加上。

正文完
 0