Failed to create directory error in Node.js - javascript

I'm new to both Node.js and Tensorflow so I apologize if this is kind of stupid. I'm also new to Stack Overflow so I apologize if this isn't the best-formatted question. I'm trying to implement Tensorflow into a Discord bot(to make a chatbot). I have some experience in Java so I was able to fix some node.js errors, but I can't figure out what this error means as it appears to be a Tensorflow error, not a node.js error and I'm completely new to Tensorflow. One more thing: I am using the provided example code found at https://www.tensorflow.org/js/guide/nodejs except for import * as tf from '#tensorflow/tfjs-node' which I replaced with const tf = require('#tensorflow/tfjs-node'); since import gives an error.
The error I am getting:
2020-03-25 21:02:38.317965: W tensorflow/core/framework/op_kernel.cc:1651] OP_REQUIRES failed at summary_kernels.cc:57 : Not found: Failed to create a directory: \/tmp; No such file or directory
(node:3504) UnhandledPromiseRejectionWarning: Error: Invalid TF_Status: 5
Message: Failed to create a directory: \/tmp; No such file or directory
at NodeJSKernelBackend.executeMultipleOutputs (C:\Users\BCG04\node_modules\#tensorflow\tfjs-node\dist\nodejs_kernel_backend.js:206:43)
at NodeJSKernelBackend.createSummaryFileWriter (C:\Users\BCG04\node_modules\#tensorflow\tfjs-node\dist\nodejs_kernel_backend.js:1580:14)
at Object.summaryFileWriter (C:\Users\BCG04\node_modules\#tensorflow\tfjs-node\dist\tensorboard.js:98:17)
at TensorBoardCallback.ensureValWriterCreated (C:\Users\BCG04\node_modules\#tensorflow\tfjs-node\dist\callbacks.js:310:40)
at TensorBoardCallback.logMetrics (C:\Users\BCG04\node_modules\#tensorflow\tfjs-node\dist\callbacks.js:296:22)
at TensorBoardCallback.<anonymous> (C:\Users\BCG04\node_modules\#tensorflow\tfjs-node\dist\callbacks.js:262:26)
at step (C:\Users\BCG04\node_modules\#tensorflow\tfjs-node\dist\callbacks.js:61:23)
at Object.next (C:\Users\BCG04\node_modules\#tensorflow\tfjs-node\dist\callbacks.js:42:53)
at C:\Users\BCG04\node_modules\#tensorflow\tfjs-node\dist\callbacks.js:36:71
at new Promise (<anonymous>)
(node:3504) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag--unhandled-rejections=strict(see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 3)
(node:3504) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
This is the code with the error:
client.once('ready', () => {
//Start TENSORFLOW tests
const model = tf.sequential();
model.add(tf.layers.dense({ units: 1, inputShape: [200] }));
model.compile({
loss: 'meanSquaredError',
optimizer: 'sgd',
metrics: ['MAE']
});
// Generate some random fake data for demo purpose.
const xs = tf.randomUniform([10000, 200]);
const ys = tf.randomUniform([10000, 1]);
const valXs = tf.randomUniform([1000, 200]);
const valYs = tf.randomUniform([1000, 1]);
// Start model training process.
async function train() {
await model.fit(xs, ys, {
epochs: 100,
validationData: [valXs, valYs],
// Add the tensorBoard callback here.
callbacks: tf.node.tensorBoard('/tmp/fit_logs_1')
});
}
train();
//End TENSORFLOW tests
console.log('Ready!');
console.log("Servers:")
client.guilds.cache.map((guild) => {
console.log(" - " + guild.name)
// List all channels
client.guilds.cache.map((channel) => {
console.log(` -- ${channel.name} (${channel.type}) - ${channel.id}`)
});
});
});

As you are running on windows machine, this directory is invalid.
Please replace this line callbacks: tf.node.tensorBoard('/tmp/fit_logs_1') with this
callbacks: tf.node.tensorBoard('C:\\Users\\BCG04')

It seems you dont have access to create tmp folder on root as indicated on the code tf.node.tensorBoard('/tmp/fit_logs_1'). Try to change the path.
For me i've change it into tf.node.tensorBoard('.tmp/fit_logs_1') so it will create .tmp directory on current working path.

Related

SessionNotCreatedError: Expected browser binary location, but unable to find binary in default location, no 'moz:firefoxOptions.binary'

When I run my test code locally, it concludes successfully, but when I try to connect the pipeline, I get the below error:
+ node login.js
(node:74) UnhandledPromiseRejectionWarning: SessionNotCreatedError: Expected browser binary location, but unable to find binary in default location, no 'moz:firefoxOptions.binary' capability provided, and no binary flag set on the command line
at Object.throwDecodedError (/opt/atlassian/pipelines/agent/build/node_modules/selenium-webdriver/lib/error.js:514:15)
at parseHttpResponse (/opt/atlassian/pipelines/agent/build/node_modules/selenium-webdriver/lib/http.js:519:13)
at /opt/atlassian/pipelines/agent/build/node_modules/selenium-webdriver/lib/http.js:441:30
at processTicksAndRejections (internal/process/task_queues.js:97:5)
From: Task: WebDriver.createSession()
at Function.createSession (/opt/atlassian/pipelines/agent/build/node_modules/selenium-webdriver/lib/webdriver.js:769:24)
at Function.createSession (/opt/atlassian/pipelines/agent/build/node_modules/selenium-webdriver/firefox/index.js:521:41)
at createDriver (/opt/atlassian/pipelines/agent/build/node_modules/selenium-webdriver/index.js:170:33)
at Builder.build (/opt/atlassian/pipelines/agent/build/node_modules/selenium-webdriver/index.js:645:16)
at login (/opt/atlassian/pipelines/agent/build/tests/login.js:16:58)
(node:74) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:74) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
My pipeline.yml file:
script:
- ls
- cd tests
- ls
- yarn install
- chmod +x geckodriver
- export PATH="$PATH:~/.tests/geckodriver"
- echo $PATH
- ls
- node login.js
My login.js code:
const { Builder, By, Key } = require('selenium-webdriver');
const firefox = require('selenium-webdriver/firefox');
function sleep(time) {
return new Promise(resolve => setTimeout(resolve, time));
}
const login = async () => {
let driver = await new Builder().forBrowser('firefox').build();
await driver.get('https:www.google.com/login');
driver.close();
};
I've tried:
export PATH="/usr/local/bin:$PATH"
export PATH="$PATH:/usr/local/bin"
export PATH="$PATH:/geckodriver"

IPFSAccessController.save ERROR: Error: Deprecated, use .toString()

i'm only trying to launch the exemple of the app kit OrbitDB which is :
import OrbitDB from "orbit-db";
import IPFS from "ipfs";
async function main () {
// Create IPFS instance
const ipfsOptions = { repo : './ipfs', }
const ipfs = await IPFS.create(ipfsOptions)
// Create OrbitDB instance
const orbitdb = await OrbitDB.createInstance(ipfs)
// Create database instance
const db = await orbitdb.keyvalue('ipfs_db')
}
main()
you can find it here : https://github.com/dappkit/aviondb#using-nodejs
but the problem is when i launch it, i got these errors :
Swarm listening on /ip4/127.0.0.1/tcp/4002/p2p/12D3KooWM7D9NdMhtxyiWiKH4XVpuZW5oDu9MbWxFmEzLsG9UynM
Swarm listening on /ip4/192.168.1.53/tcp/4002/p2p/12D3KooWM7D9NdMhtxyiWiKH4XVpuZW5oDu9MbWxFmEzLsG9UynM
Swarm listening on /ip4/127.0.0.1/tcp/4003/ws/p2p/12D3KooWM7D9NdMhtxyiWiKH4XVpuZW5oDu9MbWxFmEzLsG9UynM
IPFSAccessController.save ERROR: Error: Deprecated, use .toString()
at CID.get toBaseEncodedString [as toBaseEncodedString] (/home/zar/Etna4/SmartContract/db_ipfs/node_modules/multiformats/cjs/src/cid.js:94:11)
at Object.writeCbor [as write] (/home/zar/Etna4/SmartContract/db_ipfs/node_modules/aviondb/node_modules/orbit-db-access-controllers/node_modules/orbit-db-io/index.js:62:14)
at async IPFSAccessController.save (/home/zar/Etna4/SmartContract/db_ipfs/node_modules/aviondb/node_modules/orbit-db-access-controllers/src/ipfs-access-controller.js:46:13)
at async Function.create (/home/zar/Etna4/SmartContract/db_ipfs/node_modules/aviondb/node_modules/orbit-db-access-controllers/src/access-controllers.js:68:20)
at async OrbitDB._determineAddress (/home/zar/Etna4/SmartContract/db_ipfs/node_modules/aviondb/node_modules/orbit-db/src/OrbitDB.js:331:37)
(node:8397) UnhandledPromiseRejectionWarning: Error: `undefined` is not supported by the IPLD Data Model and cannot be encoded
at undefinedEncoder (/home/zar/Etna4/SmartContract/db_ipfs/node_modules/#ipld/dag-cbor/cjs/index.js:47:9)
at objectToTokens (/home/zar/Etna4/SmartContract/db_ipfs/node_modules/cborg/cjs/lib/encode.js:175:20)
at Object (/home/zar/Etna4/SmartContract/db_ipfs/node_modules/cborg/cjs/lib/encode.js:149:9)
at objectToTokens (/home/zar/Etna4/SmartContract/db_ipfs/node_modules/cborg/cjs/lib/encode.js:184:10)
at Object (/home/zar/Etna4/SmartContract/db_ipfs/node_modules/cborg/cjs/lib/encode.js:149:9)
at objectToTokens (/home/zar/Etna4/SmartContract/db_ipfs/node_modules/cborg/cjs/lib/encode.js:184:10)
at encodeCustom (/home/zar/Etna4/SmartContract/db_ipfs/node_modules/cborg/cjs/lib/encode.js:214:18)
at Object.encode (/home/zar/Etna4/SmartContract/db_ipfs/node_modules/cborg/cjs/lib/encode.js:236:10)
at Object.encode (/home/zar/Etna4/SmartContract/db_ipfs/node_modules/#ipld/dag-cbor/cjs/index.js:85:41)
at put (/home/zar/Etna4/SmartContract/db_ipfs/node_modules/ipfs-core/src/components/dag/put.js:35:25)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:8397) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
(node:8397) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
i seriously don't know what to do, i tried to clear the cache, to delete node_modules and package-lock.json, and do a npm install, but nothing changed, i got the same error, do you have any idea to fix this ?
This error clearly points to an incompatibility between IPFS and OrbitDB.
The latest version of js-ipfs that OrbitDB v0.26.1 supports is 0.55.4.
You should change the ipfs (or ipfs-core) version in your package.json to ^0.55.4.
Note: The upcoming OrbitDB v0.27, will support the latest IPFS version.

How can I solve login error on discord.js [duplicate]

This question already has answers here:
Why am I getting a ReferenceError: AbortController is not defined in Discord.js v13?
(3 answers)
Closed 1 year ago.
const {Client, Intents} = require('discord.js');
const { token } = require('./config.json');
const client = new Client({ intents: [Intents.FLAGS.GUILDS] });
client.once('ready', () => {
console.log('Ready!');
});
client.login(token);
I have this code, every time i try to run it returns me the same error:
(node:13284) UnhandledPromiseRejectionWarning: ReferenceError:
AbortController is not defined
at RequestHandler.execute (C:\Users\Luis\Vainas\Pruebas\node_modules\discord.js\src\rest\RequestHandler.js:172:15)
at RequestHandler.execute (C:\Users\Luis\Vainas\Pruebas\node_modules\discord.js\src\rest\RequestHandler.js:176:19)
at RequestHandler.push (C:\Users\Luis\Vainas\Pruebas\node_modules\discord.js\src\rest\RequestHandler.js:50:25)
at async WebSocketManager.connect (C:\Users\Luis\Vainas\Pruebas\node_modules\discord.js\src\client\websocket\WebSocketManager.js:128:9)
at async Client.login (C:\Users\Luis\Vainas\Pruebas\node_modules\discord.js\src\client\Client.js:245:7)
(Use node --trace-warnings ... to show where the warning was
created) (node:13284) UnhandledPromiseRejectionWarning:
Unhandled promise rejection. This error originated either by throwing
inside of an async function without a catch block, or by rejecting a
promise which was not handled with .catch(). To terminate the node
process on unhandled promise rejection, use the CLI flag
--unhandled-rejections=strict (see
https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode).
(rejection id: 2) (node:13284) [DEP0018] DeprecationWarning: Unhandled
promise rejections are deprecated. In the future, promise rejections
that are not handled will terminate the Node.js process with a
non-zero exit code.
Dont know how to fix it. I tried and investigate on the documentation but cant find the solution.
I've added this line to my code to find the error:
process.on('unhandledRejection', error => {
console.error('Unhandled promise rejection:', error);
});
Getting this:
{ code: 500, method: 'get', path: '/gateway/bot', requestData:
{ json: undefined, files: [] } }
The AbortController package was introduced in Node.js v16 (?). So you need to upgrade your Node.js version. Discord.js v13 requires you to use Node.js v16 and higher as stated in their documentation.
Depending on your operating system, you can either install 64bits or 32bits version of Node.js. Head over to the official website and download 16.8.x (Current, Latest Features) Windows installer.
After installation, verify the version by typing node -v in your console.

UnhandledPromiseRejectionWarning while starting code while sharding

I am trying to run my index.js file which runs my bot.js file. When I did node index.js, I got this error. Index.js is sharding my bot.js file (discord.js)
(node:7284) UnhandledPromiseRejectionWarning: Error [SHARDING_READY_DIED]: Shard 0's process exited before its Client became ready.
at Shard.onDeath (C:\Users\Sochum\Desktop\BobloxBot\node_modules\discord.js\src\sharding\Shard.js:158:16)
at Object.onceWrapper (events.js:422:26)
at Shard.emit (events.js:315:20)
at Shard._handleExit (C:\Users\Sochum\Desktop\BobloxBot\node_modules\discord.js\src\sharding\Shard.js:384:10)
at ChildProcess.emit (events.js:315:20)
at Process.ChildProcess._handle.onexit (internal/child_process.js:277:12)
(node:7284) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 7)
It doesn't actually say what the error is. Here is my index.js code:
const { ShardingManager } = require('discord.js');
const manager = new ShardingManager('./bot.js', {
totalShards:4,
token: "#",
})
manager.on('shardCreate', shard => console.log(`Launched shard ${shard.id}`));
manager.spawn();
Here is my bot.js file code
https://pastebin.com/RW8abmKP
I am not sure why I am getting this error, but It might have something to do with the code starting in bot.js
new EconomyClient().start(require(`./config`).token, './commands', './index');
The spawnTimeout can be set to -1 or Infinity to prevent future errors:
https://discord.js.org/#/docs/main/stable/class/ShardingManager?scrollTo=spawn. This can also happen if you call ShardingManager#spawn before attaching a listener to the shardCreate event which could create a race condition possibly preventing the shard 0 to perform a successful launch.

Naming collision in react native app start

I'm using the out-of-the box react native framework to try to build a new app.
i used the following commands ind CMD (Windows 10).
node -v:
v8.12.0
npm -v:
6.4.1
mkdir react-native-workspace
cd react-native-workspace
npm install -g create-react-native-app
create-react-native-app Exercise2
cd Exercise2
npm start
ERROR 12:42 (node:15564) UnhandledPromiseRejectionWarning: Error: jest-haste-map: #providesModule naming collision: Duplicate module
name: my-new-project Paths:
C:\Users\wp_99\Dokumenter\react-native-workspace\Exercise2\package.json
collides with
C:\Users\wp_99\Documents\react-native-workspace\Exercise2\package.json
This error is caused by a #providesModule declaration with the same
name across two different files.
at setModule (C:\Users\wp_99\Documents\react-native-workspace\Exercise2\node_modules\metro\node_modules\jest-haste-map\build\index.js:462:17)
at workerReply (C:\Users\wp_99\Documents\react-native-workspace\Exercise2\node_modules\metro\node_modules\jest-haste-map\build\index.js:512:9)
at
at process._tickCallback (internal/process/next_tick.js:189:7) ERROR 12:42 (node:15564) UnhandledPromiseRejectionWarning: Unhandled
promise rejection. This error originated either by throwing inside of
an async function without a catch block, or by rejecting a promise
which was not handled with .catch(). (rejection id: 2) (node:15564)
[DEP0018] DeprecationWarning: Unhandled promise rejections are
deprecated. In the future, promise rejections that are not handled
will terminate the Node.js process with a non-zero exit code.
It's a bug in the metro-bundler. You should create rn-cli.config.js and add this configuration to it:
For react-native>=0.57
const blacklist = require('metro-config/src/defaults/blacklist');
module.exports = {
resolver:{
blacklistRE: blacklist([
/nodejs-assets\/.*/,
/android\/.*/,
/ios\/.*/
])
},
};
react-native < 0.57
const blacklist = require('metro/src/blacklist');
module.exports = {
getBlacklistRE: function() {
return blacklist([
/nodejs-assets\/.*/,
/android\/.*/,
/ios\/.*/
]);
},
};
You can read more here.
I've added the following to rn-cli.config.js
const blacklist = require('metro-config/src/defaults/blacklist');
module.exports = {
resolver: {
blacklistRE: blacklist([
/node_modules\/.*\/node_modules\/react-native\/.*/,
])
},
};

Categories