gpt4 book ai didi

node.js - 尝试链接本地 npm 模块时出现 E404

转载 作者:搜寻专家 更新时间:2023-10-31 23:11:05 25 4
gpt4 key购买 nike

docs 之后尝试将本地模块与 npm 链接时出现 404 错误

在本地模块目录中,它似乎正确地创建了一个全局链接:

$ npm link
/usr/local/lib/node_modules/my-module-name -> /Users/XXX/my-module-directory/my-module-name

但是在那之后我尝试从其他项目目录链接它时我收到 404 错误:

$ npm link my-module-name
npm ERR! code E404
npm ERR! 404 Not Found: my-module-name@latest

我尝试取消链接模块并再次链接或更改版本,但它不起作用。

这是完整的日志:

0 info it worked if it ends with ok
1 verbose cli [ '/Users/XXX/.nvm/versions/node/v8.2.1/bin/node',
1 verbose cli '/Users/XXX/.nvm/versions/node/v8.2.1/bin/npm',
1 verbose cli 'link',
1 verbose cli 'my-module-name' ]
2 info using npm@5.3.0
3 info using node@v8.2.1
4 verbose npm-session 7d82e8d8dc1bdc83
5 silly install loadCurrentTree
6 silly install readGlobalPackageData
7 http fetch GET 404 https://registry.npmjs.org/my-module-name 2304ms
8 silly fetchPackageMetaData error for my-module-name@latest 404 Not Found: my-module-name@latest
9 verbose stack Error: 404 Not Found: my-module-name@latest
9 verbose stack at fetch.then.res (/Users/XXX/.nvm/versions/node/v8.2.1/lib/node_modules/npm/node_modules/pacote/lib/fetchers/registry/fetch.js:41:19)
9 verbose stack at tryCatcher (/Users/XXX/.nvm/versions/node/v8.2.1/lib/node_modules/npm/node_modules/bluebird/js/release/util.js:16:23)
9 verbose stack at Promise._settlePromiseFromHandler (/Users/XXX/.nvm/versions/node/v8.2.1/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:512:31)
9 verbose stack at Promise._settlePromise (/Users/XXX/.nvm/versions/node/v8.2.1/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:569:18)
9 verbose stack at Promise._settlePromise0 (/Users/XXX/.nvm/versions/node/v8.2.1/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:614:10)
9 verbose stack at Promise._settlePromises (/Users/XXX/.nvm/versions/node/v8.2.1/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:693:18)
9 verbose stack at Async._drainQueue (/Users/XXX/.nvm/versions/node/v8.2.1/lib/node_modules/npm/node_modules/bluebird/js/release/async.js:133:16)
9 verbose stack at Async._drainQueues (/Users/XXX/.nvm/versions/node/v8.2.1/lib/node_modules/npm/node_modules/bluebird/js/release/async.js:143:10)
9 verbose stack at Immediate.Async.drainQueues (/Users/XXX/.nvm/versions/node/v8.2.1/lib/node_modules/npm/node_modules/bluebird/js/release/async.js:17:14)
9 verbose stack at runCallback (timers.js:781:20)
9 verbose stack at tryOnImmediate (timers.js:743:5)
9 verbose stack at processImmediate [as _immediateCallback] (timers.js:714:5)
10 verbose cwd /Users/XXX/my-project-directory
11 verbose Darwin 16.6.0
12 verbose argv "/Users/XXX/.nvm/versions/node/v8.2.1/bin/node" "/Users/XXX/.nvm/versions/node/v8.2.1/bin/npm" "link" "my-module-name"
13 verbose node v8.2.1
14 verbose npm v5.3.0
15 error code E404
16 error 404 Not Found: my-module-name@latest
17 verbose exit [ 1, true ]

最佳答案

您正在使用 NVM 安装版本的 Node.js 来运行 npm link my-module-name,但您没有运行 npm link(在你模块的目录)使用相同的版本。

初始链接是在 /usr/local/lib/node_modules 中创建的,但是当您使用 NVM 时,每个 Node.js 版本都有自己的“lib”目录,在您的示例中 /Users/XXX/.nvm/versions/node/v8.2.1/lib/node_modules,这是一个不同的目录。

关于node.js - 尝试链接本地 npm 模块时出现 E404,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45596426/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com