Object 但是当我尝试使用 -g 标记全局安装-6ren">
gpt4 book ai didi

javascript - Benchmark.js 模块无法在 Nodejs 中全局找到

转载 作者:搜寻专家 更新时间:2023-11-01 00:13:40 25 4
gpt4 key购买 nike

如果我安装 Benchmark.js在本地使用 npm install benchmark 一切正常:

require("benchmark") > Object

但是当我尝试使用 -g 标记全局安装 Benchmark npm install benchmark -g 时,Nodejs 找不到该模块(首先删除本地安装的基准测试):

require("benchmark") > Error: Cannot find module 'benchmark'

我在 Windows 和 Linux 下都试过了。同样的结果。 在本地工作,在全局范围内不工作。任何人都可以帮助我为什么?

mongodb 模块在全局范围内工作。

最佳答案

您可以使用 npm link 来完成。例如 - express - npm link express

npm install -g express
cd <your-application-development-path>
npm link express

将创建一个符号链接(symbolic link) express

xxx@xxx:~/Programming/web/foo$ ls -lrt node_modules
total 12
drwxr-xr-x 2 xxxx xxxx 4096 2011-12-21 17:07 .bin/
lrwxrwxrwx 1 xxxx xxxx 38 2011-12-21 17:07 express -> ../../../node/lib/node_modules/express/

关于javascript - Benchmark.js 模块无法在 Nodejs 中全局找到,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8551536/

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