我在具有以下结构的目录中创建了一个简单的npm软件包:
随机数生成器(目录名称)
然后,我使用npm pack
创建了random-number-generator-1.0.0.tgz
文件。我还有一个名为npm-hosted的npm存储库。
我需要能够将此包卷曲到本地本地服务器上的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的错误:
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
即使我给了它绝对的相对文件路径,它也似乎找不到我要上传的文件。我在做错什么吗?
答案 0 :(得分:1)
curl的-F "field=/some/file"
将按字面意义发送一个字符串/some/file
作为field
的内容。要发送文件的内容,您需要在文件路径前加上@
符号,即-F "field=@/some/file"
。您可以在curl's manual中找到它。