我正在使用 npm 和 YARN 来管理项目的依赖项。正如这个问题所建议的:How do I add comments to package.json for npm install? 我使用以下格式以便能够在 pacakge.json 中包含注释。这是一个示例:
"scripts": {
"////":"LIVE BROWSER RELOAD",
"serve:patternlab": "BUILD_TO='patternlab' browser-sync start --config browsersync.config.js",
"serve:site": "browser-sync start --config browsersync.config.js",
"////":"LINTING COMMANDS",
"lint:js": "eslint $npm_package_config_src_js --ignore-pattern **/vendor/**/*.js || true",
"lint:css": "sass-lint $npm_package_config_src_css**/*.scss -v -q || true",
"lint": "npm-run-all -p lint:js lint:css",
}
Run Code Online (Sandbox Code Playgroud)
这种格式可以很容易地看到每组脚本正在做什么。但是,每当我运行yarn add添加新包时,它都会删除除最后一个注释(移到对象顶部scripts)之外的所有注释,并删除换行符。我可以做些什么来避免这种情况发生吗?
我有一个带有 Bootstrap 的 Rails 5 应用程序,我用纱线安装了它。我做了以下事情:
yarn add bootstrap
bootstrap@^3.3.7:
version "3.3.7"
resolved "https://registry.yarnpkg.com/bootstrap/-/bootstrap-3.3.7.tgz#5a389394549f23330875a3b150656574f8a9eb71"
Run Code Online (Sandbox Code Playgroud)
在 application.css 上
*= require bootstrap/dist/css/bootstrap
Run Code Online (Sandbox Code Playgroud)
在 application.js 上
//= require bootstrap/dist/js/bootstrap
//= require rails-ujs
//= require @fnando/sparkline/dist/sparkline
//= require_tree .
Run Code Online (Sandbox Code Playgroud)
关于资产.rb
Rails.application.config.assets.paths << Rails.root.join('node_modules')
Rails.application.config.assets.paths << Rails.root.join('node_modules/bootstrap/dist/fonts')
Rails.application.config.assets.precompile << %r{node_modules/bootstrap/dist/fonts/[\w-]+\.(?:eot|svg|ttf|woff2?)$}
Run Code Online (Sandbox Code Playgroud)
尽管如此,当我在生产环境(Heroku)上访问它时,我得到了
ActionController::RoutingError (No route matches [GET] "/fonts/glyphicons-halflings-regular.ttf"):
Run Code Online (Sandbox Code Playgroud)
我$icon-font-path: "node_modules/bootstrap/dist/fonts";也尝试添加到我的 scss 中,但这也不起作用
我使用vue-cli进行全局安装yarn,但vue出现“未找到命令”错误。为什么会发生这种情况?我该如何解决这个问题?
一些有趣的调试信息:
$ yarn global list
yarn global v1.7.0
info "qbrt@0.2.5" has binaries:
- qbrt
info "vue-cli@2.9.6" has binaries:
- vue
- vue-init
- vue-list
info "webpack@4.16.0" has binaries:
- webpack
Done in 0.56s.
$ ls $(yarn global bin)
$
Run Code Online (Sandbox Code Playgroud)
正如你所看到的,我的二进制文件目录似乎是空的......
在yarn upgrade根目录中运行时,它仅升级根目录的package.json和yarn.lock,但我需要升级workspace dependencied.
除了使用之外,还有其他方法可以做到这一点吗yarn upgrade-interactive?
我将 Rails 6 应用程序作为 Docker 容器启动,但是当它启动 Rails 服务器时,它不断给出错误:
warning Integrity check: System parameters don't match
website_1 | error Integrity check failed
website_1 | error Found 1 errors.
website_1 |
website_1 |
website_1 | ========================================
website_1 | Your Yarn packages are out of date!
website_1 | Please run `yarn install --check-files` to update.
website_1 | ========================================
website_1 |
website_1 |
website_1 | To disable this check, please change `check_yarn_integrity`
website_1 | to `false` in your webpacker config file (config/webpacker.yml).
Run Code Online (Sandbox Code Playgroud)
那么为什么这不起作用呢?我在 Dockerfile …
我有这个本机应用程序运行良好,但突然出现此错误:
error: bundling failed: Error: Unable to resolve module `fs` from `node_modules/eslint/lib/cli-engine/cli-engine.js`: fs could not be found within the project.
Run Code Online (Sandbox Code Playgroud)
我第一次拿到它时,我只是在测试这个应用程序,做我一整天都在做的事情,没有什么新鲜事,没有什么异常。现在我什至无法在我的设备上启动该应用程序。
我用这个脚本启动应用程序:yarn start-fresh从我的 package.json:
"start-fresh": "cd android/ && ./gradlew clean && cd .. && rm -rf node_modules/ && yarn install && react-native start --reset-cache"
Run Code Online (Sandbox Code Playgroud)
然后在一个新的终端选项卡中,我执行yarn android. 它在第二个选项卡中加载了所有内容,但是当我返回到第一个选项卡(我运行的位置yarn start-fresh)时,它加载了一些东西,但随后出现错误。我不记得安装任何新软件包或更新软件包或类似的东西......
我尝试在线搜索解决方案,但找不到任何有用的信息。另外,在错误之后我有这个列表:
If you are sure the module exists, try these steps:
1. Clear watchman watches: watchman watch-del-all
2. Delete node_modules: rm -rf node_modules and run yarn …Run Code Online (Sandbox Code Playgroud) 有没有办法追踪这种构建问题?即会显示更详细的错误信息的标志?我的项目非常像默认的 vue cli 项目。直到今天早上,它已经运行了好几个月。
$ vue-cli-service build --mode dev
? Building for dev...
ERROR Failed to compile with 0 errors 12:06:07 PM
ERROR Build failed with errors.
error Command failed with exit code 1.
Run Code Online (Sandbox Code Playgroud) 我的项目中需要 Tesseract,所以我首先yarn add tesseract.js使用了yarn add --dev @types/tesseract.js. 当我尝试使用时ng serve,出现以下错误:
ERROR in node_modules/tesseract.js/src/index.d.ts:98:60 - error TS2591: Cannot find name 'Buffer'. Do you need to install type definitions for node? Try `npm i @types/node` and then add `node` to the types field in your tsconfig.
98 | CanvasRenderingContext2D | File | Blob | ImageData | Buffer;
Run Code Online (Sandbox Code Playgroud)
有谁知道如何解决这个问题?提前致谢
所以今天我一直在尝试将 postscss-loader 从 3.0.0 版本迁移到 4.0.2
我注意到从 4.0.0 版开始,他们添加了 postCSS 作为对等依赖项,所以我添加了 postcss 7.0.27 版。我没有选择 8,因为我也使用了“postcss-import”,这依赖于版本 7。这应该没问题,因为 postcss-loader 可以同时使用版本 7 和 8。
但是现在在运行时,我收到了所有 scss 文件的相同错误消息:
Error: [object Object] is not a PostCSS plugin
由于消息不是真正的描述性,解决问题已成为一种真正的试错方法。到目前为止没有成功。
这是我的 webpack.config.ts:
import postCSSImport from 'postcss-import';
import autoPrefixerFlexbox from 'postcss-flexbugs-fixes';
import autoPrefixer from 'autoprefixer';
const BrowserList = {
mobile: ['android >= 4', 'ios >= 8'],
desktop: ['firefox >= 40', 'chrome >= 49', 'edge >= 12', 'opera >= 47', 'ie >= 11', 'safari >= 9'],
designer: ['firefox >= …Run Code Online (Sandbox Code Playgroud) 我在我的服务器上安装纱线没有任何错误,当我运行时出现yarn -v这个错误我认为纱线没有正确安装,有什么问题?
/usr/share/yarn/lib/cli.js:46100
let {
^
SyntaxError: Unexpected token {
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:374:25)
at Object.Module._extensions..js (module.js:417:10)
at Module.load (module.js:344:32)
at Function.Module._load (module.js:301:12)
at Module.require (module.js:354:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (/usr/share/yarn/bin/yarn.js:24:13)
at Module._compile (module.js:410:26)
at Object.Module._extensions..js (module.js:417:10)
Run Code Online (Sandbox Code Playgroud)