尝试构建 css 时出现 Tailwindcss 错误

尝试学习顺风,但是当我尝试构建 CSS 时,我不断收到错误。我关注了多个视频,每次遇到这个错误。

这是我不断收到的错误。 $ npm 运行构建

> platfomr@1.0.0 build C:UsersghostDropboxportfolio projectDiscovery TV Platform
> tailwind build assest/styles.css -o public/styles.css

internal/modules/cjs/loader.js:463
  throw e;
  ^

Error: Package exports for 'C:Usersghostnode_modulescolorette' do not define a valid '.' target
    at resolveExportsTarget (internal/modules/cjs/loader.js:460:13)
    at resolveExports (internal/modules/cjs/loader.js:393:16)
    at Function.Module._findPath (internal/modules/cjs/loader.js:492:20)
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:787:27)
    at Function.Module._load (internal/modules/cjs/loader.js:693:27)
    at Module.require (internal/modules/cjs/loader.js:864:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at Object.<anonymous> (C:Usersghostnode_modulesautoprefixerlibautoprefixer.js:3:17)      
    at Module._compile (internal/modules/cjs/loader.js:971:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1011:10) {
  code: 'MODULE_NOT_FOUND'
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! platfomr@1.0.0 build: `tailwind build assest/styles.css -o public/styles.css`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the platfomr@1.0.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:UsersghostAppDataRoamingnpm-cache_logs2020-11-22T07_01_12_878Z-debug.log

这是我的 json 文件

{
  "name": "platfomr",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "build": "tailwindcss build assest/styles.css -o public/styles.css"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "tailwindcss": "^2.0.1"
  }
}
enter code here

任何帮助将不胜感激。先感谢您。

stack overflow Tailwindcss error when trying to build css
原文答案

答案:

作者头像
npm i tailwindcss@latest autoprefixer@latest

为我解决了问题

作者头像

经过进一步研究,我在 Github 表单上找到了答案 - https://github.com/tailwindlabs/tailwindcss/discussions/2054

基本上,如果您运行的是 node v13 版本,则需要更新到更高版本。

Tailwindcss 不提交 package.lock 文件,并使用 semver 进行 autoprefixer 依赖,这在以后的次要版本中添加了 colorette,导致这些错误节点版本的用户突然中断。

作者头像

看来您可能缺少尾风所要求的依赖。您可以尝试在您的软件包的目录中运行 npm install -D postcss 。为我工作!

相关问题