我尝试将包发布到 npm,但每次都会出现此错误。为什么?

时间:2021-03-19 14:50:06

标签: node.js npm

我尝试将包发布到 npm,但每次都出现此错误。

npm ERR! code ERR_INVALID_ARG_TYPE
npm ERR! The "path" argument must be of type string. Received undefined

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/garax/.npm/_logs/2021-03-19T14_44_29_986Z-debug.log

2021-03-19T14_44_29_986Z-debug.log:

0 verbose cli [ '/usr/bin/node', '/usr/bin/npm', 'publish' ]
1 info using npm@7.6.3
2 info using node@v15.12.0
3 timing config:load:defaults Completed in 2ms
4 timing config:load:file:/usr/lib/node_modules/npm/npmrc Completed in 0ms
5 timing config:load:builtin Completed in 0ms
6 timing config:load:cli Completed in 2ms
7 timing config:load:env Completed in 0ms
8 timing config:load:file:/home/garax/Documents/cryptme/.npmrc Completed in 0ms
9 timing config:load:project Completed in 1ms
10 timing config:load:file:/home/garax/.npmrc Completed in 1ms
11 timing config:load:user Completed in 1ms
12 timing config:load:file:/usr/etc/npmrc Completed in 0ms
13 timing config:load:global Completed in 0ms
14 timing config:load:cafile Completed in 0ms
15 timing config:load:validate Completed in 1ms
16 timing config:load:setUserAgent Completed in 0ms
17 timing config:load:setEnvs Completed in 1ms
18 timing config:load Completed in 8ms
19 verbose npm-session 5177b76d17bb3059
20 timing npm:load Completed in 16ms
21 verbose publish [ '.' ]
22 timing command:publish Completed in 20ms
23 verbose stack TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined
23 verbose stack     at new NodeError (node:internal/errors:329:5)
23 verbose stack     at validateString (node:internal/validators:129:11)
23 verbose stack     at join (node:path:1081:7)
23 verbose stack     at flatten (/usr/lib/node_modules/npm/lib/utils/flat-options.js:50:10)
23 verbose stack     at Publish.publishConfigToOpts (/usr/lib/node_modules/npm/lib/publish.js:140:12)
23 verbose stack     at Publish.publish (/usr/lib/node_modules/npm/lib/publish.js:58:32)
24 verbose cwd /home/garax/Documents/cryptme
25 verbose Linux 5.11.2-arch1-1
26 verbose argv "/usr/bin/node" "/usr/bin/npm" "publish"
27 verbose node v15.12.0
28 verbose npm  v7.6.3
29 error code ERR_INVALID_ARG_TYPE
30 error The "path" argument must be of type string. Received undefined
31 verbose exit 1

我的代码中的所有路径都是字符串。

Npm 版本:7.6.3 Nodejs 版本:15.12.0

1 个答案:

答案 0 :(得分:1)

这个问题的解决方法是先在publishConfig文件中的package.json对象下添加~/.npm。 稍后,在 .gitignore 文件中添加 npm publish。 现在您将能够轻松Sub Macro1() Range("J4:M15,E5:G14,E5:G14").Select Range("E5").Activate Selection.ClearContents Range("G18").Select End Sub 而不会出现任何错误。