这看起来像是一个简单的问题和一个简单的答案,
npm install @react-native-community/checkbox
但它不起作用。我有一个错误说该包依赖于react-native-windows,所以我也下载了这个包,这导致无法解决我的问题。
我真的不明白为什么会发生...
这是我的 package.json:
{
"main": "node_modules/expo/AppEntry.js",
"scripts": {
"start": "expo start",
"android": "expo start --android",
"ios": "expo start --ios",
"web": "expo start --web",
"eject": "expo eject"
},
"dependencies": {
"@react-native-community/checkbox": "^0.5.6",
"expo": "~39.0.2",
"expo-status-bar": "~1.0.2",
"moviedb-promise": "^3.1.2",
"react": "16.13.1",
"react-dom": "16.13.1",
"react-image": "^4.0.3",
"react-native": "https://github.com/expo/react-native/archive/sdk-39.0.2.tar.gz",
"react-native-web": "~0.13.12",
"react-native-windows": "^1.0.0",
"react-tinder-card": "^1.3.1"
},
"devDependencies": {
"@babel/core": "~7.9.0"
},
"private": true
}
Run Code Online (Sandbox Code Playgroud)
这是我的代码:
import React from 'react'
import { View, Text } from 'react-native';
import CheckBoxSetting …Run Code Online (Sandbox Code Playgroud) 下面给出 Node.js 代码,我尝试使用 https 作为项目所需但出现错误
类型错误 [ERR_INVALID_PROTOCOL]:不支持协议“http:”。预期为“https:”
const express = require("express");
var https = require("https");
const app = express();
app.get("/", function(req, res) {
const url = "http://api.openweathermap.org/data/2.5/weather?q=Gwalior&appid=4b01458a2b74d57ff37f136f382ac4d5&units=metric";
https.get(url, function(response) {
console.log(response.statusCode)
});
res.send("Server is Up and Running");
})
app.listen(3000, function() {
console.log("Server is running on port 3000.");
})
Run Code Online (Sandbox Code Playgroud)
完整的错误堆栈跟踪:
TypeError [ERR_INVALID_PROTOCOL]: Protocol "http:" not supported. Expected "https:"
at new ClientRequest (_http_client.js:151:11)
at request (https.js:316:10)
at Object.get (https.js:320:15)
at C:\Users\Public\Documents\WeatherProject\app.js:12:10
at Layer.handle [as handle_request] (C:\Users\Public\Documents\WeatherProject\node_modules\express\lib\router\layer.js:95:5)
at next (C:\Users\Public\Documents\WeatherProject\node_modules\express\lib\router\route.js:137:13)
at Route.dispatch (C:\Users\Public\Documents\WeatherProject\node_modules\express\lib\router\route.js:112:3) …Run Code Online (Sandbox Code Playgroud) 这个问题可能看起来很愚蠢,但就像两周前一样,我安装它没有任何问题。现在看起来是这样的:

ng 添加@ngx-formly/schematics --ui-theme=material
我尝试在材料和 cdk 模块之后/之前安装它,但结果是相同的。我还尝试安装所有单独的正式模块(基于我之前创建的项目),但出现此错误:
The package that you are trying to add does not support schematics. You can try using a different version of the package or contact the package author to add ng-add support.
Run Code Online (Sandbox Code Playgroud)
我还尝试删除节点模块和yarn.lock并再次初始化它,但仍然不起作用。而且当我创建表单时它也不会显示。我也尝试用yarn add ...或-ui-theme=bootstrap来安装它,但结果是一样的。在安装之前也尝试过服务(在堆栈上的某个地方读取它),但它也不起作用。
我听说节点 v.15.6.0 有一些问题,但我不确定是否是这样。这也是我的版本:
纱线版本是 1.22.5
更新:我尝试使用纱线升级--最新升级所有软件包,然后再次正式安装。之后:
ng add @ngx-formly/schematics --ui-theme=material
Run Code Online (Sandbox Code Playgroud)
我明白了:
An unhandled exception occurred: Cannot find module '@schematics/angular/utility/config'
Require stack:
- /home/wiktor/angular-material-template/node_modules/@ngx-formly/schematics/utils/ast.js
- /home/wiktor/angular-material-template/node_modules/@ngx-formly/schematics/src/ng-add/index.js
- /home/wiktor/angular-material-template/node_modules/@angular-devkit/schematics/tools/export-ref.js
- /home/wiktor/angular-material-template/node_modules/@angular-devkit/schematics/tools/index.js
- /home/wiktor/angular-material-template/node_modules/@angular/cli/utilities/json-schema.js
- /home/wiktor/angular-material-template/node_modules/@angular/cli/models/command-runner.js
- /home/wiktor/angular-material-template/node_modules/@angular/cli/lib/cli/index.js
- /usr/lib/node_modules/@angular/cli/lib/init.js
- /usr/lib/node_modules/@angular/cli/bin/ng …Run Code Online (Sandbox Code Playgroud) 我正在尝试建立一个反应项目。但是,当我运行 npm install 时,它会抛出此错误:
npm ERR! code EBADPLATFORM
npm ERR! notsup Unsupported platform for inotify@1.4.6: wanted {"os":"linux","arch":"any"} (current: {"os":"darwin","arch":"x64"})
npm ERR! notsup Valid OS: linux
npm ERR! notsup Valid Arch: any
npm ERR! notsup Actual OS: darwin
npm ERR! notsup Actual Arch: x64
Run Code Online (Sandbox Code Playgroud)
显然,我的 Mac 似乎不支持这个库。我希望一些解决方法可以解决这个问题,而不是删除这个库。请建议我如何解决这个问题。
我的package-lock.json并且package.json没有指定用于在我的存储库中生成的node.js 版本package-lock.json。
我可以使用迭代node版本来nvm查看哪个版本git diff对我的存储库中的前一个package-lock文件的产量最小。我想知道是否有一种不那么详尽和繁琐的方法可以做到这一点。是否有任何提示可以从锁定文件中“逆向工程”或“提取”节点版本?
动机:我不想package-lock.json在每次提交时不断更改我的版本,并且在 CI 中始终使用相同的节点版本。
node.js node-modules npm-shrinkwrap npm-install package-lock.json
Npm 安装对我来说失败了
\n我在节点:12.18.3,npm:6.14.6\n对于我的其他队友来说,它工作得很好
\n我试过
\n重新安装 Node 和 npm
\n也尝试过 nvm
\nnpm 缓存清理 \xe2\x80\x93force
\n删除了node_modules
\n删除了 package-lock json
\n还增加了缓冲区的大小
\nhttp.postbuffer=524288000
\nhttp.maxrequestbuffer=100M
\n日志
\nIN-GN-52242:ui amar.tangade$ npm install
\n\n\n云预安装 /Users/amar.tangade/Desktop/cloud/ui\nnodetasks/check-install.js
\n
x----------------------------------------警告--------- ------------------------------x\nCloud ui 应在“/Users/amar.tangade/g/cloud /ui"\nx-------------------------------------------------------- - - - - - - - - - - - - - - - - - - - - X
\nnpm WARN …
当我的脚本导入nodejieba时,我遇到了这个错误。
\n未找到名为 \xe3\x80\x8cModule:无法解析“C:\\Users\\user\\Documents\\cchatbigdata\\node_modules@mapbox\\node-pre-gyp\”中的“aws-sdk” \lib\\util'\xe3\x80\x8d
\n起初,反应运行良好,我的脚本工作正常。
\n然后我npm install nodejieba --save-dev \n并在 TestedData.js 中添加import nodejieba from 'nodejieba' 。
\n即使我不使用nodejieba的功能,我的反应也遇到了这个错误。
\n我开始搜索有关 无法解析'aws-sdk'的相关问题。
\n大多数人在使用webpack时遇到这个错误,但我不使用webpack,我只是导入nodejieba。
\n我尝试了解node_modules下的node-pre-gyp\\lib\\util。
\n但它是由React创建的(我使用npx create-react-app),所以我认为如果更改文件react可能会关闭。
\n我认为react和nodejieba之间有问题。
\n我的浏览器显示这些错误,我发现它们都与node-pre-gyp\\lib\\util有关。
./node_modules/@mapbox/node-pre-gyp/lib/util/s3_setup.js\nModule not found: Can't resolve 'aws-sdk' in 'C:\\Users\\kevin\\Documents\\cchatbigdata\\node_modules\\@mapbox\\node-pre-gyp\\lib\\util'\nconsole.<computed> @ index.js:1\nhandleErrors @ webpackHotDevClient.js:174\npush../node_modules/react-dev-utils/webpackHotDevClient.js.connection.onmessage @ webpackHotDevClient.js:213\nindex.js:1 \n./node_modules/@mapbox/node-pre-gyp/lib/util/s3_setup.js\nModule not found: Can't resolve 'mock-aws-s3' in 'C:\\Users\\kevin\\Documents\\cchatbigdata\\node_modules\\@mapbox\\node-pre-gyp\\lib\\util'\nconsole.<computed> @ index.js:1\nhandleErrors @ webpackHotDevClient.js:174\npush../node_modules/react-dev-utils/webpackHotDevClient.js.connection.onmessage @ webpackHotDevClient.js:213\nindex.js:1 \n./node_modules/@mapbox/node-pre-gyp/lib/util/s3_setup.js\nModule not found: Can't resolve 'nock' in 'C:\\Users\\kevin\\Documents\\cchatbigdata\\node_modules\\@mapbox\\node-pre-gyp\\lib\\util'\nconsole.<computed> @ index.js:1\nhandleErrors @ webpackHotDevClient.js:174\npush../node_modules/react-dev-utils/webpackHotDevClient.js.connection.onmessage @ webpackHotDevClient.js:213\nRun Code Online (Sandbox Code Playgroud)\n也许必须修复node_modules下的node-pre-gyp。
\n这是我的 TestData.js
import {useState, useEffect} from …Run Code Online (Sandbox Code Playgroud) TL;DR 打包我的本地 npm 包工作正常,它忽略非分发文件,但从它的文件夹安装它包括所有文件。
环境:
我有一个小型可重用组件库 ( ./common/components),我想在我的应用程序之间共享。我正在使用 Babel 将其src代码构建到一个lib文件夹中 - 这似乎工作正常。当我运行npm pack命令时,我可以看到只有lib文件夹和package.json文件包含在包 TGZ 文件中。但是,当我使用 将该包安装在我的一个应用程序中时npm i ../../common/components,该包的所有代码(src、node_modules、.babelrc.json、package-lock.json等)都会包含在该应用程序的node_modules文件夹中。
我做错了什么,或者我误解了什么?有没有办法让我只安装lib文件夹?
这是我的组件包的代码:
package.json:
{
"name": "components",
"version": "1.0.0",
"main": "lib/*",
"files": [
"lib/*"
],
"scripts": {
"clean": "rimraf ./lib",
"postinstall": "npm run build",
"prebuild": "npm run clean",
"build": "babel src --out-dir lib --copy-files" …Run Code Online (Sandbox Code Playgroud)我正在尝试进行简单的用户登录,并且想将哈希值和盐存储在 PostgreSQL 数据库中。
const {Client} = require("pg");
const bcrypt = require('bcrypt');
const client = new Client({
user:"xxxxxxx",
host:"xxxxxxxxxxxxxxxxxx",
database:"xxxxxxxxx",
password:"xxxxxxxxxxxxxxxxxxxxxxx",
port: 1234
});
client.connect()
const saltRounds: number = 10;
const newUserHash = (username: String, password: String) => {
bcrypt.genSalt(saltRounds, function(err: Error, salt: String) {
bcrypt.hash(password, salt, function(err: Error, hash: String) {
//send it to database
});
});
}
Run Code Online (Sandbox Code Playgroud)
但我不断收到此错误;Module not found: Can't resolve 'pg-native'。使用import pg from 'pg'对我来说不起作用,我不知道该怎么办了。
我有一个 npm 包设置如下
project
|
|-- package.json
|
|-- workspace_a
| |-- package.json
| |-- index.js
|
|-- workspace_b
| |-- package.json
| |
| |-- src
| | |-- index.js
| | |
| | |-- folder_1
| | | |-- index.js
| | |
| | |-- folder_2
| | |-- index.js
| |
| |-- dist
| |-- index.js
| |
| |-- folder_1
| | |-- index.js
| |
| |-- folder_2
| |-- index.js
Run Code Online (Sandbox Code Playgroud)
主项目文件已针对工作区进行了正确配置,工作区的project.json …
node-modules ×10
node.js ×7
npm ×4
npm-install ×3
reactjs ×3
angular ×1
babeljs ×1
database ×1
expo ×1
express ×1
javascript ×1
macos ×1
postgresql ×1
react-native ×1
yarnpkg ×1