我在一个目录中创建了一个简单的npm包,其结构如下:
随机数生成器(目录名)
然后我使用npm pack创建我的random-number-generator-1.0.0.tgz文件。我还有一个名为npm的npm存储库。
我需要能够将这个包cURL到本地关系的npm托管存储库中。我尝试了以下命令:
curl -u user:password -X POST "http://localhost:8081/service/rest/v1/components?repository=npm-hosted" -F "npm.asset=C:\Projects\npm-nexus-test\random-number-generator\random-number-generator-1.0.0.tgz" -v
但是,我从nexus.exe窗口得到以下错误:
2019-09-08 18:57:50,174+0100 WARN [qtp901422593-77] admin org.sonatype.nexus.siesta.internal.UnexpectedExceptionMapper - (ID dbf90a0a-8c94-4e27-bd20-c902a6f8367f) Response: [500] 'ERROR: (ID dbf90a0a-8c94-4e27-bd20-c902a6f8367f) java.lang.NullPointerException'; mapped from: java.lang.NullPointerException
2019-09-08 18:59:40,793+0100 INFO [qtp901422593-79] admin org.sonatype.nexus.repository.upload.internal.UploadManagerImpl - Uploading component with parameters: repository="npm-hosted" format="npm"
2019-09-08 18:59:40,795+0100 INFO [qtp901422593-79] admin org.sonatype.nexus.repository.upload.internal.UploadManagerImpl - Asset with parameters: file="null"
2019-09-08 18:59:40,800+0100 WARN [qtp901422593-79] admin org.sonatype.nexus.siesta.internal.UnexpectedExceptionMapper - (ID 9db49b76-e338-4aa6-850c-d2deebd15dba) Unexpected exception: java.lang.NullPointerException
java.lang.NullPointerException: null这个来自卷曲的错误:
curl -u admin:admin -X POST "http://localhost:8081/service/rest/v1/components?repository=npm-hosted" -F npm.asset=random-number-generator-1.0.0.tgz -v
Note: Unnecessary use of -X or --request, POST is already inferred.
* Trying ::1...
* TCP_NODELAY set
* Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 8081 (#0)
* Server auth using Basic with user 'admin'
> POST /service/rest/v1/components?repository=npm-hosted HTTP/1.1
> Host: localhost:8081
> Authorization: Basic YWRtaW46YWRtaW4=
> User-Agent: curl/7.55.1
> Accept: */*
> Content-Length: 177
> Expect: 100-continue
> Content-Type: multipart/form-data; boundary=------------------------2766893a4b807008
>
< HTTP/1.1 100 Continue
< HTTP/1.1 500 Server Error
< Date: Sun, 08 Sep 2019 18:13:25 GMT
< Server: Nexus/3.18.1-01 (OSS)
< X-Content-Type-Options: nosniff
< Content-Type: text/plain;charset=utf-8
< X-Siesta-FaultId: c3cc2a39-9db4-42fc-a11e-25e930ad3cdc
< Content-Length: 79
* HTTP error before end of send, stop sending
<
ERROR: (ID c3cc2a39-9db4-42fc-a11e-25e930ad3cdc) java.lang.NullPointerException* Closing connection 0它似乎找不到我的文件上传,即使我给它绝对相对的文件路径。我做错了什么吗?
发布于 2019-09-08 20:04:15
curl的-F "field=/some/file"将字面上发送一个字符串/some/file作为field内容。要发送文件的内容,您需要在其路径前面加上@符号,即-F "field=@/some/file"。您可以在卷曲手册中找到这个。
https://stackoverflow.com/questions/57845228
复制相似问题