How can I start using web3 version 1.x - npm

In the web3 version 1.x docs: https://web3js.readthedocs.io/en/1.0/getting-started.html it says to install web 3 using
npm install web3
but this installs version 0.2x.00.
so what should I do?

Install from the github repo using the 1.0 branch directly:
npm install git+https://github.com/ethereum/web3.js.git\#1.0ES6
EDIT: Adding example install into a new project directory.
$ npm install git+https://github.com/ethereum/web3.js.git\#1.0ES6
> web3#1.0.0-beta.24 postinstall C:\cygwin\home\adamk\eth\web3-1.0\node_modules\web3
> lerna bootstrap
lerna info version 2.9.0
lerna info Bootstrapping 20 packages
lerna info lifecycle preinstall
lerna info Installing external dependencies
lerna info Symlinking packages and binaries
lerna info lifecycle postinstall
lerna info lifecycle prepublish
lerna info lifecycle prepare
lerna success Bootstrapped 20 packages
npm WARN saveError ENOENT: no such file or directory, open 'C:\cygwin\home\adamk\eth\web3-1.0\package.json'
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN enoent ENOENT: no such file or directory, open 'C:\cygwin\home\adamk\eth\web3-1.0\package.json'
npm WARN web3-1.0 No description
npm WARN web3-1.0 No repository field.
npm WARN web3-1.0 No README data
npm WARN web3-1.0 No license field.
+ web3#1.0.0-beta.24
added 1 package in 65.026s

Related

NPM install not work and make lock-json file

Hi I'm trying to install npm to run a kit.
my node version is: v12.18.3
my npm version is: 6.14.6
my folder is "test" and I'm installing npm with this command:
Kian#DESKTOP-CL16DA7 MINGW64 /d/markitdone/test
$ npm install
npm WARN saveError ENOENT: no such file or directory, open 'D:\markitdone\test\package.json'
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN enoent ENOENT: no such file or directory, open 'D:\markitdone\test\package.json'
npm WARN test No description
npm WARN test No repository field.
npm WARN test No README data
npm WARN test No license field.
up to date in 0.845s
found 0 vulnerabilities
Could someone help me please?
Before you use npm install.
You need to create a project, either React, Vue.js or Angular in your test directory

NPM install only creating a package-lock.json?

I am working on a Microsoft Surface 3 running Windows 10. I use git bash for windows for file system management. I'm running npm version 6.14.4 and node version 12.16.2
I'm currently working on an app for some school work and want to run a lite-server instead of vscode's go live extension.
My understanding is that npm install should be run outside of the application as a best practice, but once it's running, you can go back in your terminal in vscode and use npm run start or npm run dev to get the server up. I learned that the two-step process from an online course where I cloned the instructor's work from his Github. In other words, he may have done some preliminary steps that I'm leaving out unintentionally.
I visited the npm docs and spend about an hour familiarizing myself with the technology. Found a nice, simple set of commands to get moving:
$ npm install lite-server --save-dev
(which I run in the project's root folder from git bash)
$ yarn add lite-server --dev # or yarn
...and add a "script" entry within your project's package.json file:
Inside package.json...
"scripts": {
"dev": "lite-server"
},
With the above script entry, you can then start lite-server via:
$ npm run dev
Problem is, I get loads of errors upon NPM install, no package.json file is generated (only a package-lock.json), and attempting npm run dev brings up multiple errors.
From NPM install, I see the following issues mostly:
I get deprecated warnings, chokidar, fsevents, urix, etc.
npm WARN deprecated chokidar#2.1.8: Chokidar 2 will break on node v14+. Upgrade to chokidar 3 with 15x less dependencies.
npm WARN deprecated fsevents#1.2.12: fsevents 1 will break on node v14+ and could be using insecure binaries. Upgrade to fsevents 2.
npm WARN deprecated urix#0.1.0: Please see https://github.com/lydell/urix#deprecated
I am always getting this package-lock.json notice, not sure what it is:
npm notice created a lockfile as package-lock.json. You should commit this file.
Obviously loads of "skipping optional dependency" warnings:
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents#^1.2.7 (node_modules\chokidar\node_modules\fsevents):
I get "no such file or directory" warnings:
npm WARN enoent ENOENT: no such file or directory, open 'C:\Users\smansfield\desktop\bootcamp_code_responses\class_content_1\activity_4\package.json'
I get these warnings:
npm WARN activity_4 No description
npm WARN activity_4 No repository field.
npm WARN activity_4 No README data
npm WARN activity_4 No license field.
From npm run dev I'm getting these errors:
npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path C:\Users\smansfield\Desktop\bootcamp_code_responses\class_content_1\activity_4\package.json
npm ERR! errno -4058
npm ERR! enoent ENOENT: no such file or directory, open 'C:\Users\smansfield\Desktop\bootcamp_code_responses\class_content_1\activity_4\package.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\smansfield\AppData\Roaming\npm-cache_logs\2020-04-26T17_59_00_317Z-debug.log
I've searched all manner of blogs for any insight on these items... No one seems to have posted about these exact items:
why NPM install is responding with so many errors, deprecation, etc.
why am I only getting package-lock.json upon install?
why am I always getting these errors when I try to spin up the lite-server, especially these ENOENT codes and path errors?
Thank you for any insight you can provide me on this. I'll most certainly pay it forward.
Sam
Try run npm init first. It will initialize your project with npm.

NPM install from inside gitlab project

I have 2 repository. One is main, second is dependency package.
In main project in .gitlab-ci.yml I have:
install_dependency:
stage: install-dep
before_script:
- npm config set strict-ssl false
- ls -la
script:
- git config --global http.sslverify false
- npm config set #my-package:registry https://${TOKEN_USERNAME}:${TOKEN_PASSWORD}#HOST/PACKAGE/PACKAGE.git
- npm i git+https://${TOKEN_USERNAME}:${TOKEN_PASSWORD}#HOST/react.git#master
Dependecy have package.json that should install using `npm -i" as dependecy:
package/mypackage: git+https://${TOKEN_USERNAME}:${TOKEN_PASSWORD}#HOST/react.git#master
A problem is that CI did not recognize path:
$ npm i git+https://${TOKEN_USERNAME}:${TOKEN_PASSWORD}#HOST/react.git#master
npm ERR! prepareGitDep 2> npm WARN install Usage of the `--dev` option is deprecated. Use `--only=dev` instead.
npm ERR! prepareGitDep npm WARN tar ENOENT: no such file or directory, open '/root/.npm/_cacache/tmp/git-clone-7b8b3c6a/node_modules/.staging/uglify-js-ce069d2e/lib/compress.js'
Use self-hosted https://verdaccio.org/ to publish NPM package solves that issue.
For publishing into Gitlab it should upgrade Gitlab package (silver ediiton).

npm ERR! 404 Not Found: 1.9.1#latest

I cloned a project to my local repo:
$ npm i
npm WARN cropper#3.1.4 requires a peer of jquery#>= 1.9.1 but none is installed. You must install peer dependencies yourself.
npm WARN The package iview is included as both a dev and production dependency.
npm WARN The package vuex is included as both a dev and production dependency.
But when I install the jquery#>= 1.9.1 dependency manually , I get can not found error:
$ npm install jquery#>= 1.9.1 --save-dev
npm ERR! code E404
npm ERR! 404 Not Found: 1.9.1#latest
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/luowensheng/.npm/_logs/2018-02-12T07_13_29_793Z-debug.log
What this line
npm WARN cropper#3.1.4 requires a peer of jquery#>= 1.9.1 but none is installed. You must install peer dependencies yourself.
means is you need to have a jquery version greater than 1.9.1
Just do
npm install jquery#^1.9.1 or npm install jquery#latest if you want the latest jquery version which is 3.x.x

npm failing to install packages with local dependency

I am having problems installing an npm package that has a file dependency off of github. When installing directly from a local package there are no problems.
The package that I am trying to install has a dependency on a package defined within on of its subdirectories.
The error I am getting is as follows:
npm ERR! code ENOLOCAL
npm ERR! Could not install from "node_modules/local-dependency-example/local-dependency" as it does not contain a package.json file.
I created the following package in order to reproduce: https://github.com/eladzlot/local-dependency-example
In order to reproduce you should create an empty package: npm init.
Then attempt to install: npm install eladzlot/local-dependency-example --save.
This problem occurs both with npm v3.10.10 and npm v5.5.1