有什么区别:
npm install [package_name] --save
和
npm install [package_name] --save-dev
这是什么意思?
我在我的package.json文件(缩短版本)中有这个:
{
"name": "a-module",
"version": "0.0.1",
"dependencies": {
"coffee-script": ">= 1.1.3"
},
"devDependencies": {
"stylus": ">= 0.17.0"
}
}
Run Code Online (Sandbox Code Playgroud)
我在Mac 10.6.8上使用NPM版本1.1.1.
当我从项目根目录运行以下命令时,它会安装dependencies 和 devDependencies:
npm install
Run Code Online (Sandbox Code Playgroud)
我的印象是这个命令安装了devDependencies:
npm install --dev
Run Code Online (Sandbox Code Playgroud)
我如何才能使它npm install只安装dependencies(所以生产环境只获得那些模块),而像npm install --dev安装两者dependencies和devDependencies?
我创建了一个module(webapp-module-storage),它有以下定义:
的package.json
{
"dependencies": {
...
},
"devDependencies": {
"gulp": "^3.9.1",
...
},
"name": "webapp-module-storage",
"scripts": {
"postinstall": "gulp build",
"test": "gulp test"
}
}
Run Code Online (Sandbox Code Playgroud)
我想我可以在安装它时使用我的模块在另一个模块中:
npm install github:myorg/webapp-module-storage#master但是,当我安装我的模块时,我收到此错误:
找不到当地的一口气
尝试运行:npm install gulp
截图
我的理解是,它gulp与我的模块一起发货,因为我宣布它,devDependencies但看起来我的npm postinstall脚本找不到gulp.
我错过了什么吗?
npm允许我们指定bundledDependencies但这样做有什么好处?我想如果我们想要确保我们得到正确的版本,即使我们引用的模块被删除,或者捆绑可能有速度优势?
有人知道bundledDependencies优于普通依赖关系的优势吗?
为方便起见,在这里提取bundledDependencies定义:
bundledDependencies
发布包时将捆绑的包名称数组.如果这拼写为"bundleDependencies",那么这也是光荣的.
例如
bundledDependencies
我是npm的新手,并不真正了解应该依赖于devDependencies的内容.我知道,对于测试库,他们应该进入dev,但对于像babel和webpack这样的东西呢?他们是不是也应该在dev中,因为他们只是用来将es6和JSX转换成vanilla JS?我的理解是,当你部署到heroku时,它已经使用必要的库进行转换,所以不需要在生产中托管它们吗?
"dependencies": {
"babel-core": "^6.7.7",
"babel-eslint": "^6.0.4",
"babel-loader": "^6.2.4",
"babel-plugin-react-transform": "^2.0.2",
"babel-plugin-transform-object-rest-spread": "^6.6.5",
"babel-plugin-transform-react-display-name": "^6.5.0",
"babel-polyfill": "^6.7.4",
"babel-preset-es2015": "^6.6.0",
"babel-preset-react": "^6.5.0",
"bootstrap": "^3.3.7",
"css-loader": "^0.23.1",
"es6-promise": "^3.2.1",
"eslint": "^2.9.0",
"eslint-plugin-babel": "^3.2.0",
"eslint-plugin-react": "^5.0.1",
"express": "^4.13.4",
"extract-text-webpack-plugin": "^1.0.1",
"file-loader": "^0.9.0",
"lodash": "^4.15.0",
"react": "^15.0.2",
"react-addons-css-transition-group": "^15.0.2",
"react-dom": "^15.0.2",
"react-redux": "^4.4.5",
"react-transform-catch-errors": "^1.0.2",
"react-transform-hmr": "^1.0.4",
"redbox-react": "^1.2.3",
"redux": "^3.5.2",
"redux-form": "^6.1.0",
"rimraf": "^2.5.2",
"style-loader": "^0.13.1",
"webpack-dev-middleware": "^1.6.1",
"webpack-hot-middleware": "^2.10.0"
},
"devDependencies": {
"babel-register": "^6.9.0",
"chai": "^3.5.0",
"mocha": "^2.5.3",
"sinon": "^1.17.4",
"webpack": …Run Code Online (Sandbox Code Playgroud) 我记得在 Next.js 12 中,dependencies和仍然遵循这个答案devDependencies的规则。但现在,当我输入 时,所有已安装的依赖项(无论它们仅用于开发还是同时用于开发和生产)都在 内。pnpm create next-appdependencies
// Next 12
"dependencies": {
"next": "12.1.2",
"react": "17.0.2",
"react-dom": "17.0.2"
},
"devDependencies": {
"@types/node": "17.0.23",
"@types/react": "17.0.43",
"@types/react-dom": "17.0.14",
"eslint": "8.12.0",
"eslint-config-next": "12.1.2",
"typescript": "4.6.3"
}
// Next 13
"dependencies": {
"@types/node": "18.11.9",
"@types/react": "18.0.25",
"@types/react-dom": "18.0.8",
"eslint": "8.27.0",
"eslint-config-next": "13.0.2",
"next": "13.0.2",
"react": "18.2.0",
"react-dom": "18.2.0",
"typescript": "4.8.4"
}
Run Code Online (Sandbox Code Playgroud)
Next.js 13 会自动为我进行缩小吗?我应该不顾create-next-app建议而手动将它们分开吗?我在文档中找不到答案。
如何在python中指定可选的依赖项setup.py?
这是我为我的开源库指定可选依赖项的尝试,但它似乎没有做太多.
https://github.com/od-eon/django-cherrypy/blob/master/setup.py
具体extra_requires在这个片段中:
setup(
name='django-cherrypy',
version='0.1',
packages=packages,
license='LICENSE',
description='cherrypy, running under django',
long_description=open('README.md').read(),
author='Calvin Cheng',
author_email='calvin@calvinx.com',
install_requires=['cherrypy-wsgiserver'],
extra_requires=['newrelic'],
url='https://github.com/od-eon/django-cherrypy',
)
Run Code Online (Sandbox Code Playgroud)
建议?
我在Angular 5上的应用程序.这是package.json的样子
{
"name": "myapp",
"version": "0.0.0",
"license": "MIT",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build --prod",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@angular/animations": "^5.2.0",
"@angular/common": "^5.2.0",
"@angular/compiler": "^5.2.0",
"@angular/core": "^5.2.0",
"@angular/forms": "^5.2.0",
"@angular/http": "^5.2.0",
"@angular/platform-browser": "^5.2.0",
"@angular/platform-browser-dynamic": "^5.2.0",
"@angular/router": "^5.2.0",
"@types/file-saver": "0.0.1",
"angular-2-dropdown-multiselect": "^1.6.0",
"angular2-csv": "^0.2.5",
"bootstrap": "^3.3.7",
"core-js": "^2.4.1",
"file-saver": "^1.3.3",
"ngx-bootstrap": "^1.9.3",
"ngx-clipboard": "^8.1.0",
"ngx-loading": "^1.0.14",
"ngx-pagination": "^3.0.0",
"ngx-toastr": "^6.4.0",
"rxjs": "^5.5.6",
"zone.js": "^0.8.19"
},
"devDependencies": …Run Code Online (Sandbox Code Playgroud) 我不知道如何解决以下对等依赖性错误.
mondwan@mondwan-All-Series:~/Documents/git/py-cli_build_tools$ sudo npm -g list | grep eslint
??? babel-eslint@7.1.1
??? eslint@3.12.2
??? eslint-config-airbnb@13.0.0
? ??? eslint-config-airbnb-base@10.0.1
??? eslint-config-eslint@3.0.0
??? eslint-plugin-import@2.2.0
? ??? eslint-import-resolver-node@0.2.3
? ??? eslint-module-utils@2.0.0
??? UNMET PEER DEPENDENCY eslint-plugin-jsx-a11y@3.0.2
??? eslint-plugin-react@6.8.0
npm ERR! peer dep missing: eslint-plugin-jsx-a11y@^2.2.3, required by eslint-config-airbnb@13.0.0
Run Code Online (Sandbox Code Playgroud)
如你所见,我已安装了eslint-plugin-jsx-a11y@3.0.2绝对满足的^2.2.3要求
eslint-config-airbnb.但是,它显示了这样的错误消息.有什么想法解决这个问题吗?
npm ×7
dependencies ×3
node.js ×3
npm-install ×2
angular ×1
angular-cli ×1
gulp ×1
javascript ×1
next.js ×1
npm-update ×1
package ×1
packages ×1
post-install ×1
pypi ×1
python ×1
save ×1
setup.py ×1