node_modules错误:node_modules / .bin中存在模块时,缺少模块postcss

时间:2020-04-24 10:55:02

标签: javascript node-modules

我正在尝试运行package.json脚本(带有yarn),但是由于缺少模块,它似乎失败了。但是,在检查节点模块时,似乎有相关的模块在那里,所以我不清楚如何解决该错误。

~/P/j/tw-tutorial ❯❯❯ yarn build:css
yarn run v1.22.4
$ postcss src/css/tailwind.css -o src/css/main.css
internal/modules/cjs/loader.js:955
  throw err;
  ^

Error: Cannot find module '../'
Require stack:
- /Users/yunti/Projects/js/tw-tutorial/node_modules/.bin/postcss
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:952:15)
    at Function.Module._load (internal/modules/cjs/loader.js:835:27)
    at Module.require (internal/modules/cjs/loader.js:1012:19)
    at require (internal/modules/cjs/helpers.js:72:18)
    at Object.<anonymous> (/Users/yunti/Projects/js/tw-tutorial/node_modules/.bin/postcss:3:1)
    at Module._compile (internal/modules/cjs/loader.js:1123:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1143:10)
    at Module.load (internal/modules/cjs/loader.js:972:32)
    at Function.Module._load (internal/modules/cjs/loader.js:872:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [ '/Users/yunti/Projects/js/tw-tutorial/node_modules/.bin/postcss' ]
}
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
~/P/j/tw-tutorial ❯❯❯ postcss src/css/tailwind.css -o src/css/main.css
fish: Unknown command: postcss
~/P/j/tw-tutorial ❯❯❯ npx postcss src/css/tailwind.css -o src/css/main.css
Cannot find module '../'
Require stack:
- /Users/yunti/Projects/js/tw-tutorial/node_modules/.bin/postcss
~/P/j/tw-tutorial ❯❯❯ ll ./node_modules/.bin | grep postcss
-rwxr-xr-x  1 yunti  staff    36B 24 Apr 10:20 postcss

更新看起来错误来自postcss(不是因为找不到postcss) postcss.config.js

module.exports = {
    plugins:[
        require('tailwindcss'),
        require('autoprefixer'),
        process.env.NODE_ENV === 'production' && require('@fullhuman/postcss-purgecss')({
            content: [
                '.src/**/*.js',
                '.src/**/*.jsx',
                './public/index.html',
            ],
            defaultExtractor: content=> content.match(/[A-Za-z0-9-_:/]+/g) || []
        })
],
};

0 个答案:

没有答案