I'm sure this is very simple as I am just starting back to learn JavaScript. I understand the basics, the logic, but I've only ever done simple scripts embedded in HTML many years ago.
version I get the error:
Cannot find module prompt-script
I have installed the library using the following command with only 1 warning about missing
repository in the JSON.
npm install --save #types/prompt-sync
I also tried to delete the installed files and do it like:
C:\Users\Username\Project>npm install --save #types/prompt-sync
When it couldn't find the module the first time.
The script is very simple:
var prompt = require('prompt-sync')();
//
// get input from the user.
//
var n = prompt('How many more times? ');
This of course is not what I wanna write but I must have the library installed wrong since I can't find the module. Any help is greatly appreciated. I'm sure it's something really simple.
Thank you
You are installing #types/prompt-sync (the TypeScript definitions for prompt-sync - even though you aren't using TypeScript) but requiring prompt-sync.
You have to install the package you are actually requiring, prompt-sync:
npm i prompt-sync
Related
I was trying to install brain.js into my javascript program with npm install brain.js, but this returned an error (it also did this on repl.it, so I don't think its a problem with my computer), so I tried to use yarn. I did yarn add brain.js , which seemed to work, but when I tried to run the examples on GitHub the program said brain was not defined in const net = new brain.NeuralNetwork(config);, which means the library was not imported.
Does anyone know why this isn't working? Keep in mind I am not experienced with javascript and just wanted to try brain.js for myself. I installed yarn with npm install yarn, so I assume this installs the latest version so I put v2 in the tags. Please correct me if I am wrong so I can change it.
I recently developed a tool that I would like to share with the community. It consists of one JS file.
According to my logic, it should work like this:
npm i -g npm-defect
npm-defect ...
I already uploaded the library to NPM, but I don’t know how to make it so that it can be called from the console.
Tell me how to compile the program correctly so that it can be run that way.
Thank you!
you can use npx, npx npm-defect , check this link to see how it works npx doc , or if you would like to package it as an executable use a node.js packager like vercel pkg
I installed AdminJS and was trying to run my application but I am coming across this Error
It says:
Error: Cannot find module '#adminjs/design-system'
Even though design-system exists and I even added it as a require statement
const AdminJSDesignSystem = require("./#adminjs/design-system");
I also tried installing it again but it gave a huge error
Right here
Please help me fix this. I have got here after being through so many errors and fixing them and even now these errors won't stop popping up.
looks like you are importing it using a relative path.
You should change that to just the package name
e.g. const AdminJSDesignSystem = require("#adminjs/design-system");
You need to do something like this:
const AdminJSDesignSystem = require("#adminjs/design-system");
Make sure you have followed the official guide of AdminJS and adminjs/design-system that:
You have the admin user right to install things on your machine.
You have installed one of Express, Hapi and Koajs. If not,
npm install express express-formidable
You have installed AdminJS. If not,
npm install adminjs #adminjs/express
Finally, install according to the official doc:
npm install styled-components #adminjs/design-system
I've been trying to get the kotlinx.serialization library working with Kotlin/JS using the create-react-kotlin-app
However, I am not so familiar with the huge nodeJS and webpack mess.
I did the following:
1) Downloaded the kotlinx.serialization library from maven repository a located it aside the nodeJS dependencies, because there is so far no any npm module for this.
2) Modified the node_modules/#jetbrains/kotlin-webpack-plugin/plugin.js in order to compile my library, in particular I added this row to the prepareLibraries function:
opts.libraries.push(opts.packagesContents[0]["_where"]+"/lib/kotlinx-serialization-runtime-js/build/classes/main/kotlinx-serialization-runtime-js.js")
3) Modified the last line in node_modules/kotlin-compiler/bin/kotlinc in order to enable the the serialization compiler plugin:
${JAVACMD:=java}" $JAVA_OPTS "${java_args[#]}" -cp "${kotlin_app[#]}" "${kotlin_args[#]}" -Xplugin=$KOTLIN_HOME/lib/kotlinx-serialization-compiler-plugin.jar
The thing is that when I run the dev server using npm start, it compiles and runs as expected, but when I run npm run build, I got the following error:
Creating an optimized production build...
Failed to compile.
warning: flag is not supported by this version of the compiler: -
Xplugin=/home/Project/archetype-frontend-kotlin/node_modules/kotlin-compiler/lib/kotlinx-serialization-compiler-plugin.jar
npm ERR! code ELIFECYCLE
And of course when I remove the -Xplugin argument, the application is throwing exceptions like this:
Can't locate argument-less serializer for class Pu…h as lists, please provide serializer explicitly.
(There is an issue on GH related to this https://github.com/Kotlin/kotlinx.serialization/issues/278)
Thanks for any help
Okay, I think I managed to make it work.
Here are the steps as I remember them:
as suggested in https://youtrack.jetbrains.com/issue/CRKA-84, did npm eject and added plugin: require.resolve('kotlin-compiler/lib/kotlinx-serialization-compiler-plugin.jar'), to webpack-kotlin-*.js files (after new KotlinWebpackPlugin).
downloaded the compiled runtime from maven (https://dl.bintray.com/kotlin/kotlinx/org/jetbrains/kotlinx/kotlinx-serialization-runtime-js/0.9.0/) and unpacked it to node-modules/kotlinx-serialization-runtime-js
hacked kotlin-compiler.js by adding the library path (there must be a better way!):
options.libraries.join(isWindows ? ';' : ':') + ":<absolute_path_to_project>/node_modules/kotlinx-serialization-runtime-js/kotlinx-serialization-runtime-js.meta.js"
copied kotlinx-serialization-runtime-js.js and kotlinx-serialization-runtime-js.js.map to node-modules/.cache/kotlin-webpack.
After this yarn start appears to be able to compile some test code that uses kotlinx-serialization, however, Idea fails to find where kotlinx.serialization module comes from.
I hope this answer inspires someone who is willing to reverse-engieer this build system to make a better fix.
I'm sorry if this doesn't count as a "Programming Question" but I found it relevant since this will make me able to do programming in the Podio API.
My question/problem is that I can't figure out the correct way to set up the Podio JavaScript SDK/API scripts. I followed "http://podio.github.io/podio-js/" but it really only explains so much.. Mostly about Node and that I need to use Node for it, but isn't there another way like simple Ajax calls?
Reason being, I don't have the possibility of running a Node server in my server background, just to make API calls, it may be effective but it sounds kind of stupid when so many other API's out there doesn't require this.
Thoughts?
podio-js is a Podio JavaScript SDK for node and the browser.
... which means you don't necessary need Node.js. To use NPM module in the browser you'll need a bundler, like Webpack:
npm install podio-js --save
npm install webpack --save-dev
Then in your app.js:
var podio = require('podio-js');
// follow the tutorial
To bundle the app:
./node_modules/.bin/webpack app.js app.bundle.js
Then include the bundle in your HTML via script tag and voilà:
<script src="app.bundle.js"></script>