我通过npm几个角度包安装,我有这个警告:
@angular/compiler-cli@7.2.5 requires a peer of typescript@>=3.1.1 <3.3
but none is installed.
You must install peer dependencies yourself.
Run Code Online (Sandbox Code Playgroud)
a) 对等依赖和公正依赖之间有什么区别?
b) 我现在应该安装什么来修复警告?
我的意思是,假设我安装了一个我知道的包“P”,但是这个 P 需要 X、Y 和 Z。我应该手动安装它们吗?好像不是很爽。。。
实际上,我安装了Angular,但是Angular需要compiler-clr和最新的需要typescript。
当我看到这个警告时,我安装了npm install typescript它给我安装了版本typescript@3.3.3,但是这个 ***compiler-clr需要 typescript@ <3.3,我现在该怎么办?
3.3对于这种类型的所有警告,我是否应该分析之前发布的打字稿版本等等?
在一个节点项目中,我发现了两种依赖:
"dependencies": {
"axios": "0.9.1",
"express": "4.13.4",
"lodash": "4.6.1",
"react": "^0.14.7",
"react-dom": "^0.14.7",
"react-redux": "^4.4.0",
"react-router": "^2.0.0",
"redux": "^3.3.1"
},
"devDependencies": {
"babel-core": "^6.5.2"
}
Run Code Online (Sandbox Code Playgroud)
我知道作者通过它安装它 npm install babel-core --save -dev
但这是为了什么?当您推送代码时,devDependencies模块仍然存在.
根据官方网站,保存电子文件的正确方法是:
npm install electron --save-dev
Run Code Online (Sandbox Code Playgroud)
实际上,运行该应用程序需要使用Electron(实际上是:)require(),这与此处票数最高的答案背道而驰。那么,即使是一个例外,为什么还要例外呢?
在阅读了一堆关于这个问题的文章并遵循这篇非常有用的文章之后:What's the Difference Between dependency, devDependencies and peerDependencies in npm package.json file?
我知道依赖项应该引用每个运行时库,而 devDependency 引用每个对开发依赖项有用的东西。
但我现在很困惑。对于生产用途,我将需要ng build --production我的 Angular 应用程序。如果我这样做npm install --production,我什至无法编译ng build --production。我需要安装npm install每个 devDependency。知道这一点后,我尝试将所有内容都放在 devDependency 下,然后我做了一个ng build --prod,生成的[dist]文件夹包含所需的所有内容,并且可以作为完整的角度应用程序。
所以,第一个问题是:除了在运行时库和开发库之间进行“纸上”区别之外,为什么我应该使用依赖项?
其他问题:为了避免依赖项的依赖项上的漏洞,我可以通过将此库放入 package.json 中来强制使用特定版本(只要主要版本相同)。但我想避免将此库放在依赖项或 devDependency 中,我应该将此库放在 peerDependency 下吗?可选依赖项 ? 捆绑依赖关系 ?
感谢您对此的任何意见。
编辑
需要示例 package.json:
{
"name": "ANGULAR_PROJECT",
"version": "X.Y.Z",
"repository": {
"type": "git",
"url": "A_GIT_URL"
},
"scripts": {
"ng": "ng",
"test": "ng test",
"e2e": …Run Code Online (Sandbox Code Playgroud) 有什么不同?我意识到它们被放入bower.json中的不同对象属性,但我似乎无法弄清楚为什么你需要两个单独的属性,为什么不只是使用一个.
从文档:
-S, --save: Save installed packages into the project’s bower.json dependencies
-D, --save-dev: Save installed packages into the project’s bower.json devDependencies
Run Code Online (Sandbox Code Playgroud)
但是没有解释两者之间的区别.什么时候应该保存依赖vs devDependencies?
我正在做一个由后端+前端组成的7+项目。现在,我面临一个需求,我需要再创建一个包含前端+后端的项目。但是存在一些可重用的前端代码,可以在两个应用程序之间重用。
我的个人结构
需求
因此,当我阅读有关图书馆的概念时,我会发现
1)创建两个前端应用程序并共享一个公共库
因为我使用通过Visual Studio创建的(如图所示asp.net角模板项目,我不能采取这种方法在这里)。两个应用程序(项目一和项目二)具有自己的FE + BE。因此,我无法将两个FE应用程序分组到同一文件夹中,并使它们使用共享库。
2)创建库并上传到npm并用作依赖项
我不能采用这种方法,因为代码是专有的,不能在网络外部共享。此外,没有本地公司npm注册表可使用公司npm。
我知道可以使用库概念来完成。但是我不了解如何在多个应用程序中完成此操作。有人可以提供解决方案吗?谢谢 !
我正在为Vue.js构建一个插件组件.使用带有vue-loader等的标准webpack配置
在一个简单的库中,我将我希望在我dependencies的package.json中"需要"的模块放入.但是,由于Webpack将我的所有代码和依赖项编译成一个包,我不知道在哪里放置依赖项:axios.
希望有人对此有所了解.
我的MEAN应用程序的文件结构如下:
root
|---> public
|----> css
|----> js
|----> controller
|----> app.js
|----> views
|----> index.html
|---> app
|----> server.js
|---> node_modules
|---> bower_components
|---> gulpfile.js
|---> package.json
|---> Procfile
Run Code Online (Sandbox Code Playgroud)
在这个应用程序中,我运行public/index.html使用gulp,
gulpfile.js:
var gulp = require('gulp');
var browserSync = require('browser-sync');
var server = require('gulp-live-server');
gulp.task('server', function() {
live = new server('app/server.js');
live.start();
})
gulp.task('serve', ['server'], function() {
browserSync.init({
notify: false,
port: process.env.PORT || 8080,
server: {
baseDir: ['public'],
routes: {
'/bower_components': 'bower_components'
} …Run Code Online (Sandbox Code Playgroud) 我package.json看起来像这样
{
"name": "hello-world",
"version": "1.0.0",
"description": "The Hello World",
"author": "",
"license": "MIT",
"scripts": {
"start": "tsc && concurrently \"npm run tsc:w\" \"npm run lite\" ",
"lite": "lite-server",
"postinstall": "typings install",
"tsc": "tsc",
"tsc:w": "tsc -w",
"typings": "typings"
},
"dependencies": {
"@angular/common": "~2.0.1",
"@angular/compiler": "~2.0.1",
"@angular/core": "~2.0.1",
"@angular/http": "~2.0.1",
"@angular/platform-browser": "~2.0.1",
"@angular/platform-browser-dynamic": "~2.0.1",
"@angular/router": "~3.0.1",
"@angular/upgrade": "~2.0.1",
"systemjs": "0.19.39",
"core-js": "^2.4.1",
"reflect-metadata": "^0.1.8",
"rxjs": "5.0.0-beta.12",
"zone.js": "^0.6.25",
"angular-in-memory-web-api": "~0.1.1",
"bootstrap": "4.0.0-alpha.4"
},
"devDependencies": {
"concurrently": "^3.0.0",
"lite-server": …Run Code Online (Sandbox Code Playgroud) 我不确定 --dev 和 @types/package-name 的作用。
我尝试将react-color包添加到我的react Native项目中并遇到了此错误
Could not find a declaration file for module 'react-color'.
Run Code Online (Sandbox Code Playgroud)
我通过使用yarn add --dev @types/react-color安装它来解决它
如果有人能详细说明我的错误的含义以及如何解决该错误,将会有所帮助。谢谢你!
npm ×5
angular ×3
node.js ×3
package.json ×3
npm-install ×2
typescript ×2
angular6 ×1
angular7 ×1
bower ×1
commonjs ×1
electron ×1
heroku ×1
javascript ×1
react-native ×1
vue.js ×1
webpack ×1