strapi 安装

作者: 中v中 | 来源:发表于2020-11-07 09:13 被阅读0次

安装strapi前的准备工作

安装strapi的环境依赖

  • Node.js >= 10.x: Node.js is a server platform which runs JavaScript. Installation guide here.
  • NPM >= 6.x: NPM is the package manager for Javascript. Installation guide here. (Make sure the database that you are using meets the requirement.)
  • Strapi支持一下数据库,选一即可:
    • MongoDB >= 3.x: MongoDB is a powerful document store. Installation guide here.
    • MySQL >= 5.6: MySQL is an open-source relational database management system. Installation guide here.
    • MariaDB >= 10.1: MarialDB is a fork of MySQL and is guaranteed to stay open source. Installation guide here.
    • PostgreSQL >= 10: PostgreSQL is an open-source object-relational database management system. Installation guide here

开始安装Strapi

npm install strapi@alpha -g
或 安装最新版 3.3.1
npm install strapi -g

安装完成后检查版本

strapi -v

输出
3.1.0-alpha.5

20201108更新

为了您首次strapi的安装和项目的创建更加方便简单,strapi最新版本使用yarn或npm命令将两者合并到一起了,下面两种方法择一即可:

使用yarn安装

yarn create strapi-app my-project --quickstart

使用npx安装 (这个成功几率高)

npx create-strapi-app my-project --quickstart

因为strapi版本的问题如果遇到error strapi.start is not a function的错误可以使用yarn develop来启动strapi.

这里记录一下连接Mongodb数据库的配置过程
Start creating your Strapi application.

? Choose your installation type Custom (manual settings)
? Choose your main database: MongoDB
? Database name: blog
? Host: 127.0.0.1
? +srv connection: false
? Port (It will be ignored if you enable +srv): 27017
? Username: admin
? Password: 123456
? Authentication database (Maybe "admin" or blank): admin
? Enable SSL connection: false

⏳ Testing database connection...
It might take a minute, please have a coffee ☕️
(node:3108) DeprecationWarning: current Server Discovery and Monitoring engine is deprecated, and will be removed in a future version. To use the new Server Discover and Monitoring engine, pass option { useUnifiedTopology: true } to the MongoClient constructor.

The app has been connected to the database successfully!

� Application generation:
√ Copy dashboard
√ Install plugin settings-manager.
√ Install plugin content-type-builder.
√ Install plugin content-manager.
√ Install plugin users-permissions.
√ Install plugin email.
√ Install plugin upload.
√ Link strapi dependency to the project.

� Your new application gatsby-blog is ready at D:\WorkSpace[gatsby](https://towait.com/all/gatsbyjs/ "gatsby")\strapi-gatsby-starter\gatsby-blog.

⚡️ Change directory:
$ cd gatsby-blog

⚡️ Start application:
$ strapi start

创建第一个应用

strapi new project-name
注意:这里的mongo的用户名和密码需要事先设定好,具体配置参考mongo配置

Generate a Strapi project

运行应用
cd my-project
strapi start

如果启动不了,试试strapi develop

Start Strapi

这时候你访问 http;//localhost:1337/ 就可以访问你的应用地址了.

相关文章

网友评论

    本文标题:strapi 安装

    本文链接:https://www.haomeiwen.com/subject/hldfbktx.html