最近我安装了几个 npm 软件包,然后我必须将其删除。现在我不确定yarn.lock文件,并认为它里面可能有一些遗留代码。
删除yarn.lock并通过运行yarn install再次生成它是一个好主意吗?
我想知道:如果您的终端的当前工作目录位于纱线工作区内部,是否有一种方法可以运行在项目根目录中定义的纱线脚本,而不将当前目录更改为工作区之外?
例如,您可以通过运行来运行特定工作区的命令yarn workspace workspace-name script-name,但是是否可以使用该yarn workspace命令来定位根包本身而不是子包?
我想使用Apple的内置表情符号字符(特别是几个表情符号,例如\ue415)在一个表达中,UILabel但我希望表情符号能够以灰度方式呈现.
我希望他们保留字符UILabel(无论是纯文本还是归属都很好).我不是在寻找混合图像/字符串解决方案(我已经拥有).
有谁知道如何做到这一点?
我正在安装stylelint-config-styled-components一个反应项目.
当我执行npm run lint:css(或直接通过CLI使用stylelint命令)时,我没有得到任何结果.我故意添加了额外的空格和重复的样式声明,所以应该有一些来自stylelint的反馈我已经破坏了规则.但是,我什么也没得到,甚至没有错误信息.有任何想法吗?
我安装了以下软件包:
我在使用以下脚本package.json:
"scripts": {
//other scripts
"lint:css": "stylelint './src/**/*.js'"
}
Run Code Online (Sandbox Code Playgroud)
我的内容.stylelintrc:
{
"processors": ["stylelint-processor-styled-components"],
"extends": [
"stylelint-config-recommended",
"stylelint-config-styled-components"
]
}
Run Code Online (Sandbox Code Playgroud)
我的项目的文件结构(我已经尝试直接在具有相同结果的文件上运行命令,所以我不认为这是一个无法找到.js文件的问题)
-root
-.stylelintrc
-src
-Components
-Directory
-ThingIWantLinted.js
-AnotherDirectory
-AnotherThingTolint.js
Run Code Online (Sandbox Code Playgroud) 我有一个项目写在 Typescript
在本地开发时:
ts-node 作为开发依赖项安装,命令是
to start: "ts-node src/index"
to init: "ts-node bin/init"
to init db: "ts-node bin/database-init"
to migrate db: "ts-node bin/database-migrate"
to add users: "ts-node bin/add-users"
Run Code Online (Sandbox Code Playgroud)
部署时:
开发依赖项被删除,应用程序被转换,命令是
to start: "node src/index"
to init: "node bin/init"
to init db: "node bin/database-init"
to migrate db: "node bin/database-migrate"
to add users: "node bin/add-users"
Run Code Online (Sandbox Code Playgroud)
因此,我被迫在我package.json将继续增长的情况下保持这一点
"scripts": {
"start": "ts-node src/index",
"start:js": "node src/index",
"init": "ts-node bin/init",
"init:js": "node bin/init",
"db:init": "ts-node bin/db-init",
"db:init:js": "node bin/db-init",
"db:migrate": "ts-node bin/db-migrate",
"db:migrate:js": …Run Code Online (Sandbox Code Playgroud) 我有一个简单的要求:在我的npm脚本package.json文件中,有以下一行:
{
"scripts": {
"example": "some-lib --argument --domain \"https://tld.com\""
}
}
Run Code Online (Sandbox Code Playgroud)
现在,我想排除“域”。
首先尝试使用$npm_package_config,它可以工作:
{
"config": {
"domain": "https://tld.com"
},
"scripts": {
"example": "some-lib --argument --domain \"$npm_package_config_domain\""
}
}
Run Code Online (Sandbox Code Playgroud)
但我想从本地.env文件加载域。
我没有找到任何解决方案来在命令行上的npm脚本中读取env文件的内容。
有人可以给我提示解决此问题的方法吗?
我正在尝试使用 node.js 和 mongoose 将数据保存在 MongoDB 地图集中。
每次使用时MySchema.save(),数据都在插入但我也收到错误消息:
UnhandledPromiseRejectionWarning: MongoWriteConcernError: No write concern mode named 'majority;' found in replica set configuration
此外,没有重复条目,数据也在插入但我也收到错误
let User = require('../models/users.models');
const username = req.body.username;
const newUser = new User({username});
newUser.save()
.then(() => res.json('user added!'))
.catch(err => res.status(400).json('Error: ' + err));
Run Code Online (Sandbox Code Playgroud)
用户模型
const mongoose = require('mongoose');
const Schema = mongoose.Schema;
var userSchema = new Schema({
username: {
type: String,
required: true,
unique: true,
trim: true,
minlength: 3
},
},
{
timestamps: true
}); …Run Code Online (Sandbox Code Playgroud) 我想为我们的前端应用程序使用 monorepo。我们希望将一些 React UI 组件划分到“/packages/ui-components”下的包文件夹中,并将应用程序保留在“/apps/app”文件夹中,然后让应用程序通过导入来使用 ui-components(简化设置) 。我们不打算很快将这些包发布到各个 npm 存储库,而只是让最终的应用程序运行。
我开始有点担心我们如何才能拥有最好的工作流程,由于某种原因,我在我的研究中找不到这个:
应用程序应该使用包中的 src 文件还是将每个包编译到 dist 文件夹并仅导入这些文件?
在工作流程方面,我们希望在不同的包中无缝工作,因此,如果有人在包中进行编辑,我们希望这些更改立即显示在应用程序中。
与使用 dist 输出相比,我看到使用源文件的一些优点和缺点。
直接使用 src 的优点:
使用 dist 的优点:
我确信我遗漏了很多细节;如今,设置良好的开发流程非常复杂,我想让我的同事尽可能简单地使用它。
TL;博士;
mono-repo 中的包应该构建到他们的 dist 中供其他人使用,还是直接从 src 导入更好。
当我尝试在 win 机器上安装节点时,我总是收到此错误:
Run Code Online (Sandbox Code Playgroud)An error occurred while applying security settings. Authenticated Users is not a valid user or group. This could be a problem with the package, or a problem connecting to a domain controller on the network. Check your network connection and click Retry, or Cancel to end the install.
可能是什么原因以及如何解决?谢谢
我刚刚升级了 gatsby 2 -> 3。
\n在幕后,它现在使用 webpack 5 而不是 4,并且现在给出了一个突出的依赖项警告,我只是无法摆脱 -raw-loader作为主项目和 gatsby 的依赖项安装,即使它是相同的版本。
我尝试在 my 中指定纱线分辨率package.json,如下所示:
"resolutions": {\n "raw-loader": "4.0.2"\n },\nRun Code Online (Sandbox Code Playgroud)\n但这似乎没有任何作用。我也尝试过:
\n "resolutions": {\n "gatsby/raw-loader": "4.0.2"\n },\nRun Code Online (Sandbox Code Playgroud)\n\xe2\xa0\x99 Caching HTML renderer compilation\n<w> [webpack.cache.PackFileCacheStrategy/webpack.FileSystemInfo] Resolving \'raw-loader/dist/cjs\' in /Users/myname/source/octue/planex-site/node_modules/gatsby/node_modules/loader-runner/lib for build dependencies doesn\'t lead to expected result \'/Users/myname/source/octue/planex-site/node_modules/raw-loader/dist/cjs.js\', but to \'/Users/myname/source/octue/planex-site/node_modules/gatsby/node_modules/raw-loader/dist/cjs.js\' instead. Resolving dependencies are ignored for this path.\n<w> at unknown 4 raw-loader/dist/cjs\n<w> at file …Run Code Online (Sandbox Code Playgroud) node.js ×4
yarnpkg ×4
npm ×3
npm-scripts ×3
webpack ×2
emoji ×1
gatsby ×1
ios ×1
iphone ×1
lerna ×1
mongodb ×1
mongoose ×1
objective-c ×1
package.json ×1
raw-loader ×1
reactjs ×1
stylelint ×1
uilabel ×1