错误:加载 PostCSS 插件失败:找不到模块“postcss-import”(Vue 2)
Posted
技术标签:
【中文标题】错误:加载 PostCSS 插件失败:找不到模块“postcss-import”(Vue 2)【英文标题】:Error: Loading PostCSS Plugin failed: Cannot find module 'postcss-import' (Vue 2) 【发布时间】:2020-01-25 23:27:18 【问题描述】:我创建了我的第一个 npm 包。我在npmjs上发布,在项目中安装包并运行后遇到了缺少'postcss-import'模块的错误。告诉我,问题可能出在哪里,在哪个文件中?我尝试了所有方法,但没有任何效果。也许这些文件有问题?
这是我的包的“package.json”文件
"_from": "some_package",
"_inBundle": false,
"_integrity": "sha512-***",
"_location": "/some_package",
"_phantomChildren": ,
"_requested":
"type": "tag",
"registry": true,
"raw": "some_package",
"name": "some_package",
"escapedName": "some_package",
"rawSpec": "",
"saveSpec": null,
"fetchSpec": "latest"
,
"_requiredBy": [
"#USER",
"/"
],
"_resolved": "https://registry.npmjs.org/some_package/-/some_package-1.0.1.tgz",
"_shasum": "***",
"_spec": "some_package",
"_where": "/home/user/vue/projects/package_name",
"author": "",
"browserslist": [
"> 1%",
"last 2 versions",
"not ie <= 8"
],
"bundleDependencies": false,
"dependencies":
"vue": "^2.6.5",
"vue-browser-detect-plugin": "^0.1.5",
"vue-element-resize-event": "^0.1.0"
,
"deprecated": false,
"description": "A Vue.js project",
"devDependencies":
"postcss-import": "^11.0.0",
"postcss-loader": "^2.1.6",
"postcss-url": "^7.2.1"
,
"engines":
"node": ">= 6.0.0",
"npm": ">= 3.0.0"
,
"license": "ISC",
"main": "src/main.js",
"name": "some_package",
"private": false,
"scripts":
"build": "node build/build.js",
"dev": "webpack-dev-server --inline --progress --config build/webpack.dev.conf.js",
"start": "npm run dev"
,
"version": "1.0.8",
"repository":
"type": "git",
"url": "git+https://github.com/user/some_package.git"
,
"bugs":
"url": "https://github.com/user/some_package/issues"
,
"homepage": "https://github.com/user/some_package#readme"
这是我的包的“.postcs-s-rc.js”文件
module.exports =
"plugins":
"postcss-import": ,
"postcss-url": ,
// to edit target browsers: use "browserslist" field in package.json
"autoprefixer":
【问题讨论】:
“运行”它是什么意思。 postcss-import 插件在你的 devDependencies 中。npm install packagename
确实安装了这些。
【参考方案1】:
你可以试试:
npm install --save-dev postcss-import
【讨论】:
以上是关于错误:加载 PostCSS 插件失败:找不到模块“postcss-import”(Vue 2)的主要内容,如果未能解决你的问题,请参考以下文章
VSCode 加载插件失败找不到模块 'eslint-plugin-prettier'
如何解决(插件 postcss)错误:找不到或无法读取要导入的文件:smui-theme. Material UI Svelte 项目