如何使用Tailwind.css进行npm构建?

qco9c6ql  于 12个月前  发布在  其他
关注(0)|答案(1)|浏览(205)

我已经完成了使用Node,Tailwindcss和Alpine js的基本站点。每当我运行像“npm start”或“npm build”这样的命令时,我都会得到一个错误。

iMac:dmMySite21 eginoj$ npm start
npm ERR! missing script: start

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/eginoj/.npm/_logs/2021-02-19T03_12_40_559Z-debug.log
iMac:dmMySite21 eginoj$ npm start
npm ERR! missing script: start

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/eginoj/.npm/_logs/2021-02-19T03_13_12_384Z-debug.log

字符串

这是我的包.json

{
  "name": "y",
  "version": "1.0.0",
  "description": "y",
  "main": "index.js",
  "scripts": {
    "build-css": "tailwindcss build src/styles.css -o public/styles.css"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "autoprefixer": "^10.2.4",
    "nodemon": "^2.0.7",
    "postcss": "^8.2.6",
    "tailwindcss": "^2.0.3"
  },
  "dependencies": {
    "alpinejs": "^2.8.0"
  }
}

postcss.config.js

module.exports = {
  plugins: [
    // ...
    require("tailwindcss"),
    require("autoprefixer")
    // ...
  ]
};


我知道我缺少一个构建脚本,但我找不到关于如何添加它的正确文档。我所尝试的一切都是错误的。

sxpgvts3

sxpgvts31#

您忘记在脚本中添加start属性和文件名。

"scripts": {
    "start": "node your-script.js"
}

字符串
在你的例子中,在package.json中添加一个start可以解决这个问题。

{
  "name": "y",
  "version": "1.0.0",
  "description": "y",
  "main": "index.js",
  "scripts": {
    "start": "node mainjsfile.js",
    "build-css": "tailwindcss build src/styles.css -o public/styles.css"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "autoprefixer": "^10.2.4",
    "nodemon": "^2.0.7",
    "postcss": "^8.2.6",
    "tailwindcss": "^2.0.3"
  },
  "dependencies": {
    "alpinejs": "^2.8.0"
  }
}

相关问题