8

我创建了我的第一个 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"
}

这是我的包的“.postcssrc.js”文件

module.exports = {
  "plugins": {
    "postcss-import": {},
    "postcss-url": {},
    // to edit target browsers: use "browserslist" field in package.json
    "autoprefixer": {}
  }
}
4

1 回答 1

11

你可以试试:

npm install --save-dev postcss-import
于 2020-11-12T01:52:04.973 回答