简体   繁体   English

node 全局安装atob

[英]node install atob globally

I am having trouble using npm packages globally with node.我在通过 node.js 全局使用 npm 包时遇到问题。 (on Mac) (在 Mac 上)

This is probably a very simple problem.这可能是一个非常简单的问题。

This seems to work if I install npm packages locally, but not globally.如果我在本地安装 npm 包,这似乎有效,但不是全局安装。

I have this code (nt.js):我有这个代码(nt.js):

atob = require ('atob');

and have installed atob as:并已将 atob 安装为:

npm install -g atob

but, when I try to run the code但是,当我尝试运行代码时

$ node nt.js
node nt.js
internal/modules/cjs/loader.js:883
  throw err;
  ^

Error: Cannot find module 'atob'
Require stack:
...

Npm shows that atob is installed globally: npm 显示 atob 是全局安装的:

$ npm list -g
npm list -g
/usr/local/lib
├── atob@2.1.2
├── npm@7.5.4
├── ohm-js@16.0.0
├── pako@2.0.4
└── pegjs@0.10.0

$ $

I looked on the npm website and they basically say that: "Tip: If you are using npm 5.2 or higher, we recommend using npx to run packages globally."我查看了 npm 网站,他们基本上说:“提示:如果您使用的是 npm 5.2 或更高版本,我们建议您使用 npx 来全局运行包。”

try this => npx install -g atob试试这个 => npx install -g atob

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM