I'm having trouble importing blockchain.info to my Node.js based project (actually an Aurelia project). Following the instructions here, I've installed blockchain.info using npm like so:
npm install --save blockchain.info
The installation works properly and the respective folder exists in the project's "node_modules" folder.
However, I don't seem to get where or how I have to set the require('blockchain.info') statement. When I put it in the project's app.js file, it generates a <script> tag with src="src/blockchain.info.js". But this file doesn't exist. What am I doing wrong?
I've got the following setup:
Node.js 6.10.3
npm 3.10.10
aurelia 0.30.0
Related
I am pretty new to javascript and react, I want to use this github https://github.com/bennychen27/LoL-Stats-Tracker.
I use Visual Studio Code.
How I tried it?
Downloaded the App as zip
Unpacked it
I have seen that this project includes a proxyserver and a client
Then I have seen, that there are in my opinion files missing within the client folder, because how I have learned, the proxyserver and the App have to get started in two separat Terminals.
So I have opened the unpacked folder in my visual Studio
I used npm install in the main directory
I deleted the client folder
I created a new client folder by using: npx create-react-app client in the main directorty
9.Then I replaced the files in this client folder with the before deleted files of the before deleted client folder
I restartet my Visual Studio
I used npm install in the new client folder
Then I added the line "proxy": "http://localhost:4000", in the package.json file of the client, because the server runs on port 4000
Then I used npm start in the main diectory and the client folder
Then the proxyserver started without problems
And the client showed this error The react-scripts command is either misspelled or could not be found.
So I used npm install again to fix that.
Then I used npm start in the client folder
Then the error 'React' must be in scope when using JSX showed up
I added import React, { Component } from 'react'; in my app.js file
A new Error showed up Module not found: Can't resolve 'moment' in .... Failed to compile.
I used
npm install --save moment
npm install --save react-moment
npm install --save moment-timezone
after that in my client folder
After a new try to start this error showed up Module not found: Can't resolve 'react-select' in ...
I used npm i react-select to fix that
Now I am gettig errors over and over again, so I want to ask you if anyone could tell me, how I can set this up correctly, because how I already said, I am new to react.
i use tsdx to create a react ui library, and i want to test it on my next.js project before pushing it to the npm package.
i have try npm link , it works well in the beginning but when i change any thing in the package files it gave me an error, module not found, but it still in the node_modules folder.
i have try to run yarn install <tsdx-project-path > but it still gave me an error
so is there any way to include my tsdx ui library in my project locally.
let's think you have following folder structure.
|---/current-project
|---/tsdx-package
So you need to run npm install ../tsdx-package from inside current-project. I'm pretty sure you forgot to add ../ to your package path.
When i try to npm run serve it stops at 98% and :
ERROR
Failed to compile with 1 error
This dependency was not found:
* #/components/HelloWorld.vue in ./node_modules/cache-loader/dist/cjs.js??ref--12-0!./node_modules/babel-loader/lib!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader-v16/dist??ref--0-1!./src/views/Home.vue?vue&type=script&lang=js
To install it, you can run: npm install --save #/components/HelloWorld.vue
I looked up for some sources but never helped. Even installing HelloWorld.vue turns an error.
It looks like one of your files is trying to load a local component called HelloWorld.vue and it may not exist in your project structure. You shouldn't try to "install" it, but rather head to the Home.vue file where this error is being triggered from (see Home.vue at th end of the error message?). Then ask yourself, do you actually want to load HelloWorld.vue?
I imagine you're following some sort of "getting started with Vue" guide and you've been instructed to include that file. You'll have to either create that file in the {YOUR_PROJECT}/src/components/ folder, or remove the code that's trying to load it.
Alternatively, this could be a configuration error in which you're trying to use the # alias but it hasn't been setup in webpack properly. Please include more info if this doesn't solve your problem.
Maybe Vue Js cli is not installed on server
// to install vue on ubuntu
npm install -g #vue/cli
// check if it was installed successfully
vue --version
#vue/cli 4.1.2
I am currently working on a website project using javascript. I am unable to call the socket.io module, which I installed using npm install socket.io.
I tried to use it in the HTML script:
<script src="/socket.io/socket.io.js"></script>
But I got an error, apparently because the module is not found.
I didn't find any other way to install it on the internet. Does anyone know a way to avoid this problem?
When you do npm install socket.io, the socked.io library is installed to a special directory called node_modules.
In your HTML file, you are trying to load the library from a path that expects it to be located in a subdirectory called socket.io in the public documents directory of your server.
You have three options:
copy the socket.io library to a directory where your server can serve it and the browser can find it
adjust the path in your script tag to point to node_modules/socket.io
load socket.io from a CDN, for example:
<script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/2.1.1/socket.io.js"></script>
I would recommend the third option.
You can install it globally using -g parameter:
npm install -g socket.io
If you don't want to do the above then you need to run the project using local node_modules dependencies. To do that:
Add the following alias in ~/.bashrc alias npm-exec='PATH=$(npm bin):$PATH'
Run all npm commands by prefixing npm-exec to use local node modules
Example: npm-exec npm build
What i want is to have a library locally that when i change it those changes are reflected in the project that is using the library.
i have check out this library here in my local machine: https://github.com/manfredsteyer/angular-oauth2-oidc
So what i'm doing right now, is that i go to the library directory and then
npm link
And then get in my project directory and do
npm link angular-oauth2-oidc
The library folder appears inside my node_modules folder but i can't manage to use it, since when i start the app ng serve it says:
Cannot find module 'angular-oauth2-oidc'
I'm importing like this:
import { OAuthModule } from 'angular-oauth2-oidc';
I've tried to add the the path under the compilerOptions of the tsconfig.json file but haven't been sucessful.
Any ideas on what i'm missing here? I've tried several suggestions i've found on angular github issues but none solved my problem.
Thanks in advance
npm link in a package folder will create a symlink in the global folder {prefix}/lib/node_modules/ that links to the package where the npm link command was executed
Dont use npm link to add a library to your project, use npm install :
npm install angular-oauth2-oidc --save
You have to install it not just link it, so use this line to with flag --save to ensure that it will be saved in your package.json
npm install [package_name] --save
You can get the package name from the source website or from
https://www.npmjs.com/package/angular2
When you say:
So what i'm doing right now, is that i go to the library directory and
then npm link
Do you mean you are executing npm link in the folder you cloned the repository in? Because if so, that's likely your issue as that's the source directory and not what's actually published as a package. You must build the library, change directory into the distribution folder for the package, and then run npm link. Then when you run builds of that library, any Angular applications with that linked will automatically have the last version of your build in their node_modules.
Also, in your Angular applications where you are using the linked library you'll want to make sure you are setting preserveSymlinks to true in your angular.json.
While you can create multiple projects (e.g. an Angular app and an Angular library) under one Angular project to make this process a bit easier, I prefer to separating these two since I like one git repository to present one module.
First, you need to link your modules to your project's package.json file. Here's how to link files locally in general:
Local dependency in package.json
Linking a plain Typescript library is pretty straight forward as you just create an entry point (usually index.ts) file and export everything you want from there. This file needs to be in the same folder as the package.json file in your project.
An Angular library is a bit different as angular modules needs to be compiled before it can be properly exported. If you just import the module to your project without compiling you will get an error stating this: cannot read property 'ɵmod'. This happens at least at the time of writing this.
So we need to compile the library and then link it:
open two terminal windows
in the first terminal, go to your Angular library's root folder and run ng build --watch
check the output folder of the compiled module, usually something like dist/[library name]
change your Angular project's package.json to point to the output folder e.g. "my-angular-library": "file:../my-angular-library/dist/my-angular-library"
run npm install in the same folder
Add path to your Angular project's tsconfig.json e.g:
compilerOptions: {
"paths": {
"my-angular-library": ["./node_modules/my-angular-library"]
}
}
Otherwise you'll get errors like Error: Symbol MyComponent declared in /path/to/library/my.component.d.ts is not exported from my-angular-library
in the second terminal, go to your Angular project's root folder and run ng serve. Make sure you serve the project only after you have installed the local dependency.
You should now be able to use components, services etc. exported via your library module.
TL;DR
for the library ng build --watch
make the library dependency to point to the output folder e.g. "my-angular-library": "file:../my-angular-library/dist/my-angular-library"
npm i
Add path to your Angular project's tsconfig.json e.g:
compilerOptions: {
"paths": {
"my-angular-library": ["./node_modules/my-angular-library"]
}
}
ng serve