我的项目中有 eslint 和一些规则。在我的 package.json 中,我有:
"lint": "eslint . --ext .js --ext .ts --ext .tsx --ignore-pattern 'node_modules/'"
。
有什么方法可以设置我想在.eslintrc.json中检查的扩展,所以在 package.json 中我刚刚设置:
"lint": "eslint"
?
包.json
{
"lint": "eslint . --ext .js --ext .ts --ext .tsx --ignore-pattern 'node_modules/'"
}
Run Code Online (Sandbox Code Playgroud)
我希望有:
paxkage.json
"lint": "eslint"
Run Code Online (Sandbox Code Playgroud) 我正在将我的应用程序部署到 github 页面,但是当我运行命令时却npm run deploy
收到错误
npm ERR! missing script: deploy
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\whoami\AppData\Roaming\npm-cache\_logs\2020-02-05T16_46_06_946Z-debug.log
Run Code Online (Sandbox Code Playgroud)
我已经在 package.json 文件中定义了部署
...
"scripts": {
"test": "jest --watchAll --verbose --coverage --runInBand",
"start": "node index.js",
"predeploy":"npm run build",
"deploy":"gh-pages -d build"
}
...
Run Code Online (Sandbox Code Playgroud) 最近我将我的角度应用程序移动到了一些不同的文件夹中。从那时起,当我想构建应用程序时,我收到此错误:
架构验证失败并出现以下错误:数据路径“”应具有必需的属性“tsConfig”
我尝试在 github 和 stackoverflow 中查找,只找到了这些链接:
https://github.com/angular/angular-cli/issues/11479
他们说我必须降级一个包:
“@Angular-devkit/build-Angular”:“^0.800.1”到“^0.12.4”
但这感觉不是正确的方式
{
"name": "@xxx/ma",
"version": "1.1.0",
"private": true,
"license": "UNLICENSED",
"scripts": {
"ng": "ng",
"start": "ng serve --proxy-config proxy.conf.js",
"build": "ng build --prod",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e",
"doc": "compodoc -p src/tsconfig.app.json -s"
},
"dependencies": {
"@angular/animations": "~8.2.1",
"@angular/cdk": "~8.2.1",
"@angular/common": "~8.2.1",
"@angular/compiler": "~8.2.1",
"@angular/core": "~8.2.1",
"@angular/flex-layout": "8.0.0-beta.27",
"@angular/forms": "~8.2.1",
"@angular/material": "~8.2.1",
"@angular/platform-browser": "~8.2.1",
"@angular/platform-browser-dynamic": "~8.2.1",
"@angular/platform-server": "~8.2.1",
"@angular/pwa": "~0.802.1",
"@angular/router": "~8.2.1",
"@angular/service-worker": "~8.2.1",
"@progress/kendo-angular-buttons": "~5.0.0", …
Run Code Online (Sandbox Code Playgroud) 我正在编写一个 React 组件库,并且不想捆绑 React,所以我将库添加到peerDependencies
而不是dependencies
.
另外,为了防止出现有关缺少对等依赖项的愚蠢警告,我将相同的库添加到该devDependencies
部分。
那不是 DRY,但固定警告对我来说比 DRY package.json 更重要。
所以问题是:是否有 DRYer 方法可以实现这一目标,或者我实际上遵循 2020 年 5 月的最佳实践?
{
"peerDependencies": {
"react": "^16.9.0",
"react-dom": "^16.9.0",
"tslib": "^1.11.0",
},
"devDependencies": {
"@types/react": "^16.9.0",
"react": "^16.9.0",
"react-dom": "^16.9.0",
"typescript": "^3.8.0"
},
"dependencies": {
// nothing here
}
}
Run Code Online (Sandbox Code Playgroud) 运行 npm start 时,出现错误 -
PS D:\React\operations_app_tut> npm start
npm ERR! path D:\React\operations_app_tut\package.json
npm ERR! code ENOENT
npm ERR! errno -4058
npm ERR! syscall open
npm ERR! enoent ENOENT: no such file or directory, open 'D:\React\operations_app_tut\package.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\IT-DI\AppData\Roaming\npm-cache\_logs\2020-12-16T05_56_02_304Z-debug.log
Run Code Online (Sandbox Code Playgroud)
检查物理路径时确保文件存在 -
项目结构供参考 -
我引用了几个网站并再次运行 -npm install 但同样的错误仍然存在。
...我为节点项目的package.json编写了一些脚本。当我在脚本中使用某些语法时,例如 BUILD_PATH= ,我只能在 WLS 命令行 (Linux) 上运行此 npm 脚本,但在 Windows 中与 bash 一起使用时,它会引发错误。我想知道是否有任何工具可以在 Windows 和 Linux 中运行这样的脚本?
示例:来自我的 package.json
"scripts":
{"build": "BUILD_PATH=../server/public react-scripts build"}
Run Code Online (Sandbox Code Playgroud)
当我使用 Linux 命令行 (WSL) 执行该命令时,一切顺利。但对于 Windows,它会抛出错误。
我知道这个命令在 Windows 中相当于什么。但我想知道有一个工具或包可以自动执行此操作。
在运行中yarn run build
我遇到以下错误:
[webpack-cli] Invalid configuration object. Webpack has been initialized using a configuration object that does not match the API schema.
- configuration.optimization has an unknown property 'moduleIDs'. These properties are valid:
object { checkWasmTypes?, chunkIds?, concatenateModules?, emitOnErrors?, flagIncludedChunks?, innerGraph?, mangleExports?, mangleWasmImports?, mergeDuplicateChunks?, minimize?, minimizer?, moduleIds?, noEmitOnErrors?, nodeEnv?, portableRecords?, providedExports?, realContentHash?, removeAvailableModules?, removeEmptyChunks?, runtimeChunk?, sideEffects?, splitChunks?, usedExports? }
-> Enables/Disables integrated optimizations.
Run Code Online (Sandbox Code Playgroud)
我不确定这是否是由于我的 webpack 模块中的弃用造成的,或者我可能还需要查看其他地方。
这是我的webpack.config.js
:
const webpack = require('webpack');
const path = require('path');
const …
Run Code Online (Sandbox Code Playgroud) 我必须使用cross-env
package.json 设置节点环境变量,但值位于.env
文件中。
我尝试过以下格式,但没有一个有效。
cross-env API_KEY=%API_KEY% && ...
Run Code Online (Sandbox Code Playgroud)
cross-env API_KEY=$API_KEY && ...
Run Code Online (Sandbox Code Playgroud)
cross-env %API_KEY% && ...
Run Code Online (Sandbox Code Playgroud) 当我yarn
在包含带有字段的 package.json 文件的目录中运行时"private": "true",
,此行将被静默删除。例如,yarn 3.1.0 中有此行为,但 npm 8.5.5 中没有此行为。
package.json ×10
npm ×4
node.js ×3
reactjs ×2
angular ×1
asp.net-core ×1
build ×1
cross-env ×1
eslint ×1
github-pages ×1
javascript ×1
tsconfig ×1
webpack ×1
yarn-v3 ×1
yarnpkg ×1