如何postcss
在本地安装模块,并通过postcss-cli
全局安装来使用它们?
例如:
postcss -u autoprefixer -o style.css index.css
如果我已经全局安装,或者两者都在本地安装,则此命令postcss-cli
有效autoprefixer
。postcss-cli
但是,如果我已在全局和autoprefixer
本地安装,它不起作用。
这个问题并不特定于 autoprefixer,因为 autoprefixer 将是一个模块,无论如何我都会在全球范围内安装什么。任何意见将是有益的。
这是我得到的错误,如果postcss-cli
在全局和autoprefixer
本地安装:
> postcss -u autoprefixer -o style.css index.css -w
module.js:327
throw err;
^
Error: Cannot find module 'autoprefixer'
at Function.Module._resolveFilename (module.js:325:15)
at Function.Module._load (module.js:276:25)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at /home/user/.nvm/versions/node/v4.4.2/lib/node_modules/postcss-cli/index.js:104:14
at Array.map (native)
at Object.<anonymous> (/home/user/.nvm/versions/node/v4.4.2/lib/node_modules/postcss-cli/index.js:97:24)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
npm ERR! Linux 3.19.0-58-generic
npm ERR! argv "/home/user/.nvm/versions/node/v4.4.2/bin/node" "/home/user/.nvm/versions/node/v4.4.2/bin/npm" "run" "css"
npm ERR! node v4.4.2
npm ERR! npm v2.15.0
npm ERR! code ELIFECYCLE
npm ERR! Node.js@1.0.0 css: `postcss -u autoprefixer -o style.css index.css -w`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the Node.js@1.0.0 css script 'postcss -u autoprefixer -o style.css index.css -w'.
npm ERR! This is most likely a problem with the Node.js package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! postcss -u autoprefixer -o style.css index.css -w
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs Node.js
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!
npm ERR! npm owner ls Node.js
npm ERR! There is likely additional logging output above.