找不到模块‘crypto-js’Ubuntu 14.04

找不到模块‘crypto-js’Ubuntu 14.04

我正在使用 node-red,我在使用从这里下载的一些软件包时遇到了一些问题github。我已按照说明获取 npm 并安装它,但我收到系统中缺少库的错误,有人遇到过同样的情况吗?

提前致谢!

lo@lo-desktop:~$ sudo npm install crypto-js
npm http GET https://registry.npmjs.org/crypto-js
npm http 200 https://registry.npmjs.org/crypto-js
npm http GET https://registry.npmjs.org/crypto-js/-/crypto-js-3.1.6.tgz
npm http 200 https://registry.npmjs.org/crypto-js/-/crypto-js-3.1.6.tgz
[email protected] node_modules/crypto-js

locate crypto-js
/home/lo/node_modules/crypto-js
/home/lo/node_modules/crypto-js/CONTRIBUTING.md
/home/lo/node_modules/crypto-js/LICENSE
/home/lo/node_modules/crypto-js/README.md
/home/lo/node_modules/crypto-js/aes.js
/home/lo/node_modules/crypto-js/bower.json
/home/lo/node_modules/crypto-js/cipher-core.js
/home/lo/node_modules/crypto-js/core.js
/home/lo/node_modules/crypto-js/crypto-js.js
/home/lo/node_modules/crypto-js/docs
/home/lo/node_modules/crypto-js/enc-base64.js
/home/lo/node_modules/crypto-js/enc-hex.js
/home/lo/node_modules/crypto-js/enc-latin1.js
/home/lo/node_modules/crypto-js/enc-utf16.js
/home/lo/node_modules/crypto-js/enc-utf8.js
/home/lo/node_modules/crypto-js/evpkdf.js
/home/lo/node_modules/crypto-js/format-hex.js
/home/lo/node_modules/crypto-js/format-openssl.js
/home/lo/node_modules/crypto-js/hmac-md5.js
/home/lo/node_modules/crypto-js/hmac-ripemd160.js
/home/lo/node_modules/crypto-js/hmac-sha1.js
/home/lo/node_modules/crypto-js/hmac-sha224.js
/home/lo/node_modules/crypto-js/hmac-sha256.js
/home/lo/node_modules/crypto-js/hmac-sha3.js
/home/lo/node_modules/crypto-js/hmac-sha384.js
/home/lo/node_modules/crypto-js/hmac-sha512.js
/home/lo/node_modules/crypto-js/hmac.js
/home/lo/node_modules/crypto-js/index.js
/home/lo/node_modules/crypto-js/lib-typedarrays.js
/home/lo/node_modules/crypto-js/md5.js
/home/lo/node_modules/crypto-js/mode-cfb.js
/home/lo/node_modules/crypto-js/mode-ctr-gladman.js
/home/lo/node_modules/crypto-js/mode-ctr.js
/home/lo/node_modules/crypto-js/mode-ecb.js
/home/lo/node_modules/crypto-js/mode-ofb.js
/home/lo/node_modules/crypto-js/package.json
/home/lo/node_modules/crypto-js/pad-ansix923.js
/home/lo/node_modules/crypto-js/pad-iso10126.js
/home/lo/node_modules/crypto-js/pad-iso97971.js
/home/lo/node_modules/crypto-js/pad-nopadding.js
/home/lo/node_modules/crypto-js/pad-pkcs7.js
/home/lo/node_modules/crypto-js/pad-zeropadding.js
/home/lo/node_modules/crypto-js/pbkdf2.js
/home/lo/node_modules/crypto-js/rabbit-legacy.js
/home/lo/node_modules/crypto-js/rabbit.js
/home/lo/node_modules/crypto-js/rc4.js
/home/lo/node_modules/crypto-js/ripemd160.js
/home/lo/node_modules/crypto-js/sha1.js
/home/lo/node_modules/crypto-js/sha224.js
/home/lo/node_modules/crypto-js/sha256.js
/home/lo/node_modules/crypto-js/sha3.js
/home/lo/node_modules/crypto-js/sha384.js
/home/lo/node_modules/crypto-js/sha512.js
/home/lo/node_modules/crypto-js/tripledes.js
/home/lo/node_modules/crypto-js/x64-core.js
/home/lo/node_modules/crypto-js/docs/QuickStartGuide.wiki



lo@lo-desktop:~$ node-red -v
Welcome to Node-RED
===================

12 Apr 09:11:41 - [info] Node-RED version: v0.13.4
12 Apr 09:11:41 - [info] Node.js  version: v0.10.25
12 Apr 09:11:41 - [info] Linux 4.2.0-27-generic ia32 LE
12 Apr 09:11:41 - [info] Loading palette nodes
12 Apr 09:11:43 - [warn] ------------------------------------------
12 Apr 09:11:43 - [warn] [rpi-gpio] Info : Ignoring Raspberry Pi specific node
12 Apr 09:11:43 - [warn] [TTN] Error: Cannot find module 'crypto-js'
12 Apr 09:11:43 - [warn] ------------------------------------------
12 Apr 09:11:43 - [info] Settings file  : /home/lo/.node-red/settings.js
12 Apr 09:11:43 - [info] User directory : /home/lo/.node-red
12 Apr 09:11:43 - [info] Flows file : /home/lo/.node-red/flows_loshora-desktop.json
12 Apr 09:11:43 - [info] Server now running at http://127.0.0.1:1880/
12 Apr 09:11:43 - [info] Starting flows
12 Apr 09:11:43 - [info] Started flows

答案1

npm 通常不需要 sudo 来安装任何东西。您可以在不使用 sudo 的情况下安装 crypto-js 模块吗?

另外,我对您的项目结构有点困惑。您的主文件夹也是您的项目文件夹吗?

此外,你始终可以在运行时使用 require 加载模块(请参阅https://nodejs.org/api/modules.html#modules_module_require_id

相关内容