I have cloned git repository https://github.com/thejh/node-curve25519 and next used npm link inside it. I am using this library in suggested way: var curve = require('curve25519');. But I am getting this error on the line curve.makeSecretKey() in this fragment:
temp.secret = crypto.randomBytes(32);
curve.makeSecretKey(temp.secret);
This is error message:
/Users/username/Workspaces/nodejs/myproject/server.js:59
curve.makeSecretKey(ctx.private);
^
TypeError: Object #<Object> has no method 'makeSecretKey'
at handlers.(anonymous function) (/Users/username/Workspaces/nodejs/myprojet/server.js:59:8)
at Socket.<anonymous> (/Users/username/Workspaces/nodejs/myproject/server.js:198:3)
at Socket.EventEmitter.emit (events.js:98:17)
at UDP.onMessage (dgram.js:440:8)
What am I doing wrong? This library should contains such method. As you can see: https://github.com/thejh/node-curve25519/blob/master/index.js
You need to also link the library from your project directory.
An example from the docs:
cd ~/projects/node-redis # go into the package directory
npm link # creates global link
cd ~/projects/node-bloggy # go into some other package directory.
npm link redis # link-install the package
In your case, the first package directory is the curve25519 git repo and if I understood your question correctly, the line you need to run in your project directory is npm link curve25519
Related
I don't understand how to import a random npm library in Svelte.
Take the scrapegoat library for example, a library to read CalDAV objects. I created a brand new Svelte project:
$ npx degit sveltejs/template my-svelte-project
$ cd my-svelte-project/
$ npm install
$ npm install -D scrapegoat
Not sure if it should be added to the devDependencies but it doesn't seem to make a lot of difference if it is not. Now, in the src/App.svelte I add this singe line in the existing <script> tag.
import scrapegoat from 'scrapegoat'
Running npm run dev throws the following error:
[!] Error: Unexpected token (Note that you need #rollup/plugin-json to import JSON files)
node_modules/scrapegoat/package.json (2:9)
1: {
2: "_from": "scrapegoat#^2.0.0",
^
3: "_id": "scrapegoat#2.0.0",
4: "_inBundle": false,
Error: Unexpected token (Note that you need #rollup/plugin-json to import JSON files)
at error (node_modules/rollup/dist/shared/rollup.js:158:30)
at Module.error (node_modules/rollup/dist/shared/rollup.js:12420:16)
at Module.tryParse (node_modules/rollup/dist/shared/rollup.js:12823:25)
at Module.setSource (node_modules/rollup/dist/shared/rollup.js:12726:24)
at ModuleLoader.addModuleSource (node_modules/rollup/dist/shared/rollup.js:22197:20)
This is what I understood from Rich Harris' reply but I am clearly missing something.
The package you’re importing imports its own package.json. Rollup won’t handle JSON imports by default, so you will need to install the json plugin and add it to your Rollup config.
I am trying to use a code snippet from a README for node-glob in CoffeeScript. I installed the package:
npm install --global glob
I am trying to use the following snippet:
var glob = require("glob")
// options is optional
glob("**/*.js", options, function (er, files) {
// files is an array of filenames.
// If the `nonull` option is set, and nothing
// was found, then files is ["**/*.js"]
// er is an error object or null.
})
and I assume its then written something similar to this in CoffeeScript:
# Cakefile
{glob} = require 'glob' # npm install --global glob
task 'glob-test', 'Testing Globs', ->
glob.sync("**/*.ts") (er, files) ->
console.log files
However, I get the following error messages:
Error: Cannot find module 'glob'
Am I doing this correctly, or is it even possible CoffeeScript and I should just abandon the whole idea?
UPDATE:
Installed the node-glob module as a locally vendored module this time using:
npm install glob
and changed {glob} to glob in the require statement.
and ran the Cakefile task again. Got this error this time.
I am trying to create the directory in public/data folder to place my read data but Getting this error while creating the directory dynamically in nodejs.
Error: ENOENT: no such file or directory, mkdir './public/data/folder'
at Object.mkdirSync (fs.js:753:3)
at /home/ubuntu/New/routes/index.js:589:14
at FSReqWrap.oncomplete (fs.js:141:20)
I have implemented my code like this by checking the folder exist or not and creating the folder when not exist using mkdirsync()
var dd = './public/data/'+ id;
if (!fs.existsSync(dd))
{
fs.mkdirSync(dd,'0777', true);
console.log("Directory Created!!");
}
Directory Created!!
mkdirSync accepts an option property recursive (default is false).
Check out the guide
So you could use:
fs.mkdirSync('/dir1/dir2', { recursive: true });
This solved issue, Running the npm with root permission
Solution:
sudo npm install -g PACKAGE-NAME --unsafe-perm=true --allow-root
I followed the directions exactly as described here (https://github.com/Elyx0/react-native-document-picker/issues/94?fbclid=IwAR2Ke7ejhPYaJcT0bS7jTZHbZvXM570C7aHQQRAvHQz56C9qzvf3W1R5SkA) but it's not working. I get this error:
RNDocumentPicker: Native module is not available, make sure you have finished the installation process and rebuilt your app
Error: not opened
at WebSocket.send (/Users/miajohansson/Desktop/bnook/node_modules/ws/lib/WebSocket.js:219:16)
at send (/Users/miajohansson/Desktop/bnook/node_modules/react-native/local-cli/server/util/webSocketProxy.js:26:12)
at WebSocket.debuggerSocket.onmessage (/Users/miajohansson/Desktop/bnook/node_modules/react-native/local-cli/server/util/webSocketProxy.js:48:48)
at WebSocket.onMessage (/Users/miajohansson/Desktop/bnook/node_modules/ws/lib/WebSocket.js:442:14)
at emitTwo (events.js:126:13)
at WebSocket.emit (events.js:214:7)
at Receiver.ontext (/Users/miajohansson/Desktop/bnook/node_modules/ws/lib/WebSocket.js:841:10)
at /Users/miajohansson/Desktop/bnook/node_modules/ws/lib/Receiver.js:536:18
at /Users/miajohansson/Desktop/bnook/node_modules/ws/lib/Receiver.js:368:7
at /Users/miajohansson/Desktop/bnook/node_modules/ws/lib/PerMessageDeflate.js:249:5
When I add DocumentPicker in my code (below), I get a TypeError: Cannot read property 'show' of defined.
import { DocumentPicker, DocumentPickerUtil } from 'react-native-document-picker';
// iPhone/Android
DocumentPicker.show({
filetype: [DocumentPickerUtil.images()],
},(error,res) => {
// Android
console.log(
res.uri,
res.type, // mime type
res.fileName,
res.fileSize
);
});
I've deleted node_modules and run npm install but I still get this error.
Please in which installation you are, npm or yarn, the installation wasn't complete. Try to redo yarn add react-native-document-picker --save or npm install react-native-document-picker --save.
All errors of sort Native module is not available, has to be solved by updating pods and rebuilding the app
I just installed Uglify.js and tried to use it to rebuild CoffeeScript, but keep getting this error. This happens when I type "cake build:browser" in the CoffeeScript directory. (I want to try my hand at modifying the CoffeeScript language.)
My Uglify.js was cloned from GitHub and the symbolic link was created in .node_libraries. Uglify is installed correctly, confirmed since it runs properly in Node and through the command line. So maybe this is a CoffeeScript problem.
Help?
/Users/myuser/projects/UglifyJS/lib/process.js:475
return options.defines[name];
^
TypeError: Cannot read property 'Array' of undefined
at get_define (/Users/myuser/projects/UglifyJS/lib/process.js:475:47)
at Array.<anonymous> (/Users/myuser/projects/UglifyJS/lib/process.js:527:32)
at walk (/Users/myuser/projects/UglifyJS/lib/process.js:215:47)
at Array.<anonymous> (/Users/myuser/projects/UglifyJS/lib/process.js:164:59)
at walk (/Users/myuser/projects/UglifyJS/lib/process.js:220:36)
at Array.<anonymous> (/Users/myuser/projects/UglifyJS/lib/process.js:146:43)
at walk (/Users/myuser/projects/UglifyJS/lib/process.js:220:36)
at /Users/myuser/projects/UglifyJS/lib/process.js:1643:37
at Array._block (/Users/myuser/projects/UglifyJS/lib/process.js:81:34)
at walk (/Users/myuser/projects/UglifyJS/lib/process.js:220:36)
OK, I was able to replicate this. But why are you cloning the UglifyJS repo? If you just do npm install uglify-js to install to the local node-modules directory (with npm 1.x), everything runs fine.
Similar issue: https://github.com/mishoo/UglifyJS/issues/140