npm audit EINVALIDTAGNAME - node.js

When I execute npm audit in a folder with the project's package.json and package-lock.json I get the following error:
0 info it worked if it ends with ok
1 verbose cli [ '/home/user/Downloads/node-v10.14.0-linux-x64/bin/node',
1 verbose cli '/home/user/Downloads/node-v10.14.0-linux-x64/bin/npm',
1 verbose cli 'audit' ]
2 info using npm#6.5.0
3 info using node#v10.14.0
4 verbose npm-session d5b5c65bd8e7ae03
5 verbose stack Error: Invalid tag name "[object Object]": Tags may not have any characters that encodeURIComponent encodes.
5 verbose stack at invalidTagName (/home/user/Downloads/node-v10.14.0-linux-x64/lib/node_modules/npm/node_modules/npm-package-arg/npa.js:87:15)
5 verbose stack at fromRegistry (/home/user/Downloads/node-v10.14.0-linux-x64/lib/node_modules/npm/node_modules/npm-package-arg/npa.js:290:13)
5 verbose stack at Function.resolve (/home/user/Downloads/node-v10.14.0-linux-x64/lib/node_modules/npm/node_modules/npm-package-arg/npa.js:77:12)
5 verbose stack at Object.keys.forEach.name (/home/user/Downloads/node-v10.14.0-linux-x64/lib/node_modules/npm/node_modules/lock-verify/index.js:26:26)
5 verbose stack at Array.forEach (<anonymous>)
5 verbose stack at Promise.all.then.result (/home/user/Downloads/node-v10.14.0-linux-x64/lib/node_modules/npm/node_modules/lock-verify/index.js:25:25)
6 verbose cwd /home/user/projects/test-npm/CRYPTOSTORAGE/repos/crypto-storage/etc/approvalClient
7 verbose Linux 3.10.0-862.14.4.el7.x86_64
8 verbose argv "/home/user/Downloads/node-v10.14.0-linux-x64/bin/node" "/home/user/Downloads/node-v10.14.0-linux-x64/bin/npm" "audit"
9 verbose node v10.14.0
10 verbose npm v6.5.0
11 error code EINVALIDTAGNAME
12 error Invalid tag name "[object Object]": Tags may not have any characters that encodeURIComponent encodes.
13 verbose exit [ 1, true ]
If this would happen to only one project - but actually it does indeed happen to all projects that I've tried (~70). There is an internal registry, but I've both removed the local .npmrc and the one in home. Also the error I was getting then was a different one.
Is this a bug or am I doing something wrong?

Not positive if this is the exact issue the author is hitting, but I ran into this error when I copy/pasted the contents of my package.json into package-lock.json. As I was searching through the JS stack trace, I realized that those files have different object formats and are not interchangeable.
This is likely your issue if npm install works fine, but npm ci and npm audit are failing with the above error.

Related

Neither NPM nor GitBash are operational at the moment. How can that be solved?

I am new to GitBash and do not know how it functions within VisualStudio Code. The challenge that I am faced with is enabling React.js to operate within VSCode. As it stands, the error message below is what's being output at this time.
D:\_Dearest_Lord_God,_please_intuitively_reveal_the_things_that_used_to_baffle_me]\_Projects-React]\node_modules\babel-jest (version: 27.2.4)
Manually installing incompatible versions is known to cause hard-to-debug issues.
If you would prefer to ignore this check, add SKIP_PREFLIGHT_CHECK=true to an .env file in your project.
That will permanently disable this message but you might encounter other issues.
To fix the dependency tree, try following the steps below in the exact order:
1. Delete package-lock.json (not package.json!) and/or yarn.lock in your project folder.
2. Delete node_modules in your project folder.
3. Remove "babel-jest" from dependencies and/or devDependencies in the package.json file in your project folder.
4. Run npm install or yarn, depending on the package manager you use.
In most cases, this should be enough to fix the problem.
If this has not helped, there are a few other things you can try:
5. If you used npm, install yarn (http://yarnpkg.com/) and repeat the above steps with it instead.
This may help because npm has known issues with package hoisting which may get resolved in future versions.
6. Check if D:\_Dearest_Lord_God,_please_intuitively_reveal_the_things_that_used_to_baffle_me]\_Projects-React]\node_modules\babel-jest is outside your project directory.
For example, you might have accidentally installed something in your home folder.
7. Try running npm ls babel-jest in your project folder.
This will tell you which other package (apart from the expected react-scripts) installed babel-jest.
If nothing else helps, add SKIP_PREFLIGHT_CHECK=true to an .env file in your project.
That would permanently disable this preflight check in case you want to proceed anyway.
P.S. We know this message is long but please read the steps above :-) We hope you find them helpful!
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! affiliate-marketing-project#0.1.0 start: `react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the affiliate-marketing-project#0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Refined_Silver\AppData\Roaming\npm-cache\_logs\2021-10-12T16_55_33_704Z-debug.log
PS D:\_Dearest_Lord_God,_please_intuitively_reveal_the_things_that_used_to_baffle_me]\_Projects-React]\affiliate-marketing-project>
I followed the instructions above, but to no avail. For starters, "babel-jest" did not exist within the dependencies section of my package.json.
Below is the message that I have been receiving, which is inside of the debug log for React within Visual Studio Code.
0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli 'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli 'start'
1 verbose cli ]
2 info using npm#6.14.15
3 info using node#v14.18.0
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info lifecycle affiliate-marketing-project#0.1.0~prestart: affiliate-marketing-project#0.1.0
6 info lifecycle affiliate-marketing-project#0.1.0~start: affiliate-marketing-project#0.1.0
7 verbose lifecycle affiliate-marketing-project#0.1.0~start: unsafe-perm in lifecycle true
8 verbose lifecycle affiliate-marketing-project#0.1.0~start: PATH: C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;D:\_Dearest_Lord_God,_please_intuitively_reveal_the_things_that_used_to_baffle_me]\_Projects-React]\affiliate-marketing-project\node_modules\.bin;C:\Program Files (x86)\Common Files\Intel\Shared Libraries\redist\intel64\compiler;C:\Python39\Scripts\;C:\Python39\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\ProgramData\chocolatey\bin;C:\Program Files\nodejs\;C:\Program Files (x86)\Yarn\bin\;C:\Program Files\Git\cmd;C:\Ruby26-x64\bin;C:\Users\Refined_Silver\AppData\Local\Microsoft\WindowsApps;C:\Users\Refined_Silver\AppData\Local\Programs\Microsoft VS Code\bin;C:\ProgramData\Refined_Silver\GitHubDesktop\bin;C:\Users\Refined_Silver\AppData\Roaming\npm;C:\Users\Refined_Silver\AppData\Local\Yarn\bin
9 verbose lifecycle affiliate-marketing-project#0.1.0~start: CWD: D:\_Dearest_Lord_God,_please_intuitively_reveal_the_things_that_used_to_baffle_me]\_Projects-React]\affiliate-marketing-project
10 silly lifecycle affiliate-marketing-project#0.1.0~start: Args: [ '/d /s /c', 'react-scripts start' ]
11 silly lifecycle affiliate-marketing-project#0.1.0~start: Returned: code: 1 signal: null
12 info lifecycle affiliate-marketing-project#0.1.0~start: Failed to exec start script
13 verbose stack Error: affiliate-marketing-project#0.1.0 start: `react-scripts start`
13 verbose stack Exit status 1
13 verbose stack at EventEmitter.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\index.js:332:16)
13 verbose stack at EventEmitter.emit (events.js:400:28)
13 verbose stack at ChildProcess.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
13 verbose stack at ChildProcess.emit (events.js:400:28)
13 verbose stack at maybeClose (internal/child_process.js:1058:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:293:5)
14 verbose pkgid affiliate-marketing-project#0.1.0
15 verbose cwd D:\_Dearest_Lord_God,_please_intuitively_reveal_the_things_that_used_to_baffle_me]\_Projects-React]\affiliate-marketing-project
16 verbose Windows_NT 10.0.19043
17 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "start"
18 verbose node v14.18.0
19 verbose npm v6.14.15
20 error code ELIFECYCLE
21 error errno 1
22 error affiliate-marketing-project#0.1.0 start: `react-scripts start`
22 error Exit status 1
23 error Failed at the affiliate-marketing-project#0.1.0 start script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]
I am not-at-all familiar with how to read what is happening within the NPM / GitBash start-up process. Everything was working fine until I installed GitBash. I would appreciate some assistance with how GitBash functions.
I would appreciate any insight as to how this can be solved. Thank you.
Have you followed step 6 and removed babel-jest in D:\_Dearest_Lord_God,_please_intuitively_reveal_the_things_that_used_to_baffle_me]\_Projects-React]\node_modules ?
react-scripts comes with babel-jest. It warns you about the conflicting installation up the tree.

ELOOP: too many symbolic links encountered

When trying to hit the command : npm install -g #angular/cli#6.1.1
Note:
I have Node.Js LTS 10.xx version, .Net Framework 4.7.2 Developer pack, and all necessary extensions in place.
Error thrown:
npm ERR! code ELOOP
npm ERR! syscall stat
npm ERR! path \\horofs**\users$\
npm ERR! errno -62
npm ERR! ELOOP: too many symbolic links encountered, stat '\\horofs06\users$\'
npm ERR! A complete log of this run can be found in:
npm ERR! \\horofs**\users$\W****\AppData\Roaming\npm-cache\_logs\2020-07-31T13_26_25_468Z-debug.log
The log states this:
0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli 'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli 'install',
1 verbose cli '-g',
1 verbose cli '#angular/cli#6.1.1' ]
2 info using npm#6.14.6
3 info using node#v10.22.0
4 verbose npm-session 8b2e687260b66580
5 silly install loadCurrentTree
6 silly install readGlobalPackageData
7 http fetch GET 200 https://registry.npmjs.org/#angular%2fcli 282ms (from cache)
8 silly pacote version manifest for #angular/cli#6.1.1 fetched in 426ms
9 verbose stack Error: ELOOP: too many symbolic links encountered, stat '\\horofs**\users$\'
9 verbose stack at eloop (C:\Program Files\nodejs\node_modules\npm\node_modules\read-package-tree\realpath.js:58:17)
9 verbose stack at realpathCached (C:\Program Files\nodejs\node_modules\npm\node_modules\read-package-tree\realpath.js:19:11)
9 verbose stack at realpathCached (C:\Program Files\nodejs\node_modules\npm\node_modules\read-package-tree\realpath.js:39:10)
9 verbose stack at realpathCached (C:\Program Files\nodejs\node_modules\npm\node_modules\read-package-tree\realpath.js:39:10)
9 verbose stack at realpathCached (C:\Program Files\nodejs\node_modules\npm\node_modules\read-package-tree\realpath.js:39:10)
9 verbose stack at realpathCached (C:\Program Files\nodejs\node_modules\npm\node_modules\read-package-tree\realpath.js:39:10)
9 verbose stack at realpathCached (C:\Program Files\nodejs\node_modules\npm\node_modules\read-package-tree\realpath.js:39:10)
9 verbose stack at realpathCached (C:\Program Files\nodejs\node_modules\npm\node_modules\read-package-tree\realpath.js:39:10)
9 verbose stack at realpathCached (C:\Program Files\nodejs\node_modules\npm\node_modules\read-package-tree\realpath.js:39:10)
9 verbose stack at realpathCached (C:\Program Files\nodejs\node_modules\npm\node_modules\read-package-tree\realpath.js:39:10)
9 verbose stack at realpathCached (C:\Program Files\nodejs\node_modules\npm\node_modules\read-package-tree\realpath.js:39:10)
9 verbose stack at realpathCached (C:\Program Files\nodejs\node_modules\npm\node_modules\read-package-tree\realpath.js:39:10)
9 verbose stack at realpathCached (C:\Program Files\nodejs\node_modules\npm\node_modules\read-package-tree\realpath.js:39:10)
9 verbose stack at realpathCached (C:\Program Files\nodejs\node_modules\npm\node_modules\read-package-tree\realpath.js:39:10)
9 verbose stack at realpathCached (C:\Program Files\nodejs\node_modules\npm\node_modules\read-package-tree\realpath.js:39:10)
9 verbose stack at realpathCached (C:\Program Files\nodejs\node_modules\npm\node_modules\read-package-tree\realpath.js:39:10)
10 verbose cwd C:\Cqe\Periscope\src\Periscope\Endava.Periscope.Web
11 verbose Windows_NT 6.3.9600
12 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "-g" "#angular/cli#6.1.1"
13 verbose node v10.22.0
14 verbose npm v6.14.6
15 error code ELOOP
Please help me.
I met a similar issue and the log said as following,
error ELOOP: too many symbolic links encountered, chmod '/Users/myname/projects/my-electron-app/node_modules/electron/cli.js'
error ELOOP: too many symbolic links encountered, open '/Users/myname/projects/my-electron-app/node_modules/electron/npm-shrinkwrap.json'
When I checked my folder and found the folder electron link to itself, so it led to a never-ending loop.
lrwxr-xr-x 1 myname staff 8 Feb 20 11:42 electron# -> electron
I checked the size and directly removed the file, then used npm install electron again. It finally worked.
So please check the link, it looks that the file in your application links to itself too.
I doubt that it should be an issue about npm because npm tries to create a link before the file is actually downloaded.
You can judge for yourself below. The disappointing situation is that you may not be able to use NodeJS when your User data is stored in a folder with more than 2,000 subfolders.
Like you, my User folder is stored on a network drive instead of C:
In "readGlobalPackageData()," the value of self.where is passed to readPackageTree. In my case, self.where = "\[domain]\users$[office location][userID]\AppData\npm." Code in realpathCached() is backing out of that path and trying to read all subfolders as it goes. When it gets to "\[domain]\users$", the "ELOOP" error is logged because there's a max depth of 2000, and my company's Users folder has more than 25,000 subfolders.
Here are two possible solutions:
First, remove -g from the install command to make the install local to the folder for your new app. The downside is that if there's an update to one of the dependencies, you'll have to install it manually everywhere you didn't use -g. That can be good if an update contains breaking changes.
Second, and I don't recommend this solution, is to edit one of the installer files. The installer is reading all the ID folders in your User folder and it's only failing because an arbitrary limits was reached. If you increase the limit, the error should go away but you're also letting the script read all the user IDs on your network. Try this at your own risk.
Open this file:
C:\Program Files\nodejs\node_modules\npm\node_modules\read-package-tree\realpath.js.
On line 18, "if (depth > 2000)," change 2000 to a number greater than the number of folders under your users$ (share) folder.
As answered by Classic Craig
You can judge for yourself below. The disappointing situation is that you may not be able to use NodeJS when your User data is stored in a folder with more than 2,000 subfolders. Like you, my User folder is stored on a network drive instead of C: In "readGlobalPackageData()," the value of self.where is passed to readPackageTree. In my case, self.where = "[domain]\users$[office location][userID]\AppData\npm." Code in realpathCached() is backing out of that path and trying to read all subfolders as it goes. When it gets to "[domain]\users$", the "ELOOP" error is logged because there's a max depth of 2000, and my company's Users folder has more than 25,000 subfolders.
I also cannot install Angular globally on my user folder on my company's mainframe. I work around this by installing it locally.
First I initialized the installation location with
npm init
and by going to the directory within the node_modules I accessed .bin folder
cd ../node_modules/.bin
The ng command can be run within the .bin folder. Then I used ng new to create a new project within the .bin folder. Then, I can use the
npm run ng <command>
here. So I can use the ng command within the project folder.

npm install error Unexpected end of JSON input while parsing near

0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli 'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli 'install',
1 verbose cli 'react-bootstrap',
1 verbose cli 'bootstrap'
1 verbose cli ]
2 info using npm#6.14.4
3 info using node#v12.17.0
4 verbose npm-session 4004d1d4d37ac517
5 silly install loadCurrentTree
6 silly install readLocalPackageData
7 http fetch GET 200 https://registry.npmjs.org/react-bootstrap 521ms
8 silly fetchPackageMetaData error for react-bootstrap#latest Unexpected end of JSON input while parsing near '...,"requirejs":"~2.1.9"'
9 http fetch GET 200 https://registry.npmjs.org/bootstrap 521ms
10 silly fetchPackageMetaData error for bootstrap#latest Unexpected end of JSON input while parsing near '...7bc2df7ec608869c9c8",'
11 timing stage:rollbackFailedOptional Completed in 0ms
12 timing stage:runTopLevelLifecycles Completed in 3560ms
13 verbose stack SyntaxError: Unexpected end of JSON input while parsing near '...,"requirejs":"~2.1.9"'
13 verbose stack at JSON.parse (<anonymous>)
13 verbose stack at parseJson (C:\Program Files\nodejs\node_modules\npm\node_modules\json-parse-better-errors\index.js:7:17)
13 verbose stack at C:\Program Files\nodejs\node_modules\npm\node_modules\node-fetch-npm\src\body.js:96:50
13 verbose stack at processTicksAndRejections (internal/process/task_queues.js:97:5)
14 verbose cwd D:\Talk2Tutor\material-kit-react-master
15 verbose Windows_NT 10.0.17134
16 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "react-bootstrap" "bootstrap"
17 verbose node v12.17.0
18 verbose npm v6.14.4
19 error Unexpected end of JSON input while parsing near '...,"requirejs":"~2.1.9"'
20 verbose exit [ 1, true ]
I got above error while running npm i react-bootstrap bootstrap. After the error occurred, I tried npm cache clean --force but it didn't resolve my problem. Then I reinstalled node and tried to install dependencies but I still get an error and installation is failed. Any one fixed this error. I tried all the things mentioned in the related question. But it didn't solve my problem. I use node v12.17.0 and npm 6.14.4.
I tried by executing command npm cache clean --force and then executed the command that caused this error and it worked fine.
Upgrade npm using npm-windows-upgrade solved the issue.
After running the command npm cache clean --force . You need to remove the package-lock.json file. This worked for me.
Popper.js is required if you're using Bootstrap JS. Check the docs

Switching Node versions give me `Cannot read property 'resolve' of undefined` from npm

I use the n version manager and when I change the Node version to 11.10 NPM stops working.
$ n latest
node/11.10.1
$ npm i sinon
npm ERR! Cannot read property 'resolve' of undefined
npm ERR! A complete log of this run can be found in:
npm ERR! /home/myuser/.npm/_logs/2019-03-04T22_12_54_458Z-debug.log
$ npm --version
6.7.0
If I change back to the previous version of Node - or any earlier version really, it starts working again.
The full output from the debug log
0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node', '/usr/local/bin/npm', 'i', 'sinon' ]
2 info using npm#6.7.0
3 info using node#v11.10.1
4 verbose npm-session d32761bbecba8a12
5 silly install loadCurrentTree
6 silly install readLocalPackageData
7 silly fetchPackageMetaData error for sinon#^7.2.7 Cannot read property 'resolve' of undefined
8 timing stage:rollbackFailedOptional Completed in 0ms
9 timing stage:runTopLevelLifecycles Completed in 73ms
10 verbose stack TypeError: Cannot read property 'resolve' of undefined
10 verbose stack at regFetch (/usr/local/lib/node_modules/npm/node_modules/npm-registry-fetch/index.js:76:23)
10 verbose stack at fetchPackument (/usr/local/lib/node_modules/npm/node_modules/pacote/lib/fetchers/registry/packument.js:42:10)
10 verbose stack at packument (/usr/local/lib/node_modules/npm/node_modules/pacote/lib/fetchers/registry/packument.js:20:10)
10 verbose stack at getManifest (/usr/local/lib/node_modules/npm/node_modules/pacote/lib/fetchers/registry/manifest.js:22:10)
10 verbose stack at manifest (/usr/local/lib/node_modules/npm/node_modules/pacote/lib/fetchers/registry/manifest.js:13:10)
10 verbose stack at Object.manifest (/usr/local/lib/node_modules/npm/node_modules/pacote/lib/fetchers/registry/index.js:17:12)
10 verbose stack at Object.Fetcher#manifest [as manifest] (/usr/local/lib/node_modules/npm/node_modules/genfun/lib/genfun.js:15:38)
10 verbose stack at manifest (/usr/local/lib/node_modules/npm/node_modules/pacote/lib/fetch.js:23:18)
10 verbose stack at pinflight (/usr/local/lib/node_modules/npm/node_modules/pacote/manifest.js:24:12)
10 verbose stack at /usr/local/lib/node_modules/npm/node_modules/promise-inflight/inflight.js:29:24
10 verbose stack at Promise._execute (/usr/local/lib/node_modules/npm/node_modules/bluebird/js/release/debuggability.js:313:9)
10 verbose stack at Promise._resolveFromExecutor (/usr/local/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:483:18)
10 verbose stack at new Promise (/usr/local/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:79:10)
10 verbose stack at _inflight (/usr/local/lib/node_modules/npm/node_modules/promise-inflight/inflight.js:28:25)
10 verbose stack at /usr/local/lib/node_modules/npm/node_modules/promise-inflight/inflight.js:22:14
10 verbose stack at tryCatcher (/usr/local/lib/node_modules/npm/node_modules/bluebird/js/release/util.js:16:23)
11 verbose cwd /tmp/foo
12 verbose Linux 4.15.0-34-generic
13 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "i" "sinon"
14 verbose node v11.10.1
15 verbose npm v6.7.0
16 error Cannot read property 'resolve' of undefined
17 verbose exit [ 1, true ]
This seems to be a problem with n, or how it bundles NPM, for (only) version 11.10 of Node. Basically the global npm install is broken.
This is resolved if one uses n to revert to an earlier version of Node and NPM and downloads the same problematic release (6.7.0).
n 11.9
npm install -g npm#6.7
n 11.10
This seems to overwrite the existing cached, global download of NPM version 6.7.0 and fix the install. The fix persists to work, even after switching between Node versions, even though the npm command is reset to point to the default each time. This means that even if you do npm i npm#6.8 -g to do a global upgrade of npm it will be reset to 6.7 the next time you switch back and forth to Node 11.10.
Are you running a version of n older than v2.1.12? n was updated in v2.1.12 to remove the previous npm node_modules folder during installation, to avoid problems when layout and content of the npm modules folder changes between versions.
If you have installed n using npm then, short version:
npm install -g n
Long version:
https://github.com/tj/n/issues/508#issuecomment-423933394
https://stackoverflow.com/a/53985680/1082434

web3 npm install fails

I seem to be struggling with getting npm to install web3
Command used:
npm install web3
Error:
npm ERR! Path must be a string. Received undefined
Logs:
info it worked if it ends with ok
1 verbose cli [ '/usr/bin/node', '/usr/bin/npm', 'install', 'web3' ]
2 info using npm#5.0.4
3 info using node#v8.1.3
4 verbose npm-session 02c74f27df35fda1
5 silly install loadCurrentTree
6 silly install readLocalPackageData
7 http fetch GET 304 https://registry.npmjs.org/web3 236ms (from cache)
8 silly pacote tag manifest for web3#latest fetched in 269ms
9 verbose stack TypeError: Path must be a string. Received undefined
9 verbose stack at assertPath (path.js:28:11)
9 verbose stack at Object.relative (path.js:1248:5)
9 verbose stack at computeVersionSpec (/usr/lib/node_modules/npm/lib/install/deps.js:282:27)
9 verbose stack at Installer.normalizeCurrentTree (/usr/lib/node_modules/npm/lib/install.js:370:69)
9 verbose stack at Array.<anonymous> (/usr/lib/node_modules/npm/node_modules/slide/lib/bind-actor.js:15:8)
9 verbose stack at LOOP (/usr/lib/node_modules/npm/node_modules/slide/lib/chain.js:15:14)
9 verbose stack at /usr/lib/node_modules/npm/node_modules/slide/lib/chain.js:18:7
9 verbose stack at iferr (/usr/lib/node_modules/npm/lib/install.js:328:5)
9 verbose stack at /usr/lib/node_modules/npm/node_modules/iferr/index.js:13:50
9 verbose stack at cb (/usr/lib/node_modules/npm/node_modules/slide/lib/async-map.js:47:24)
9 verbose stack at /usr/lib/node_modules/npm/node_modules/call-limit/call-limit.js:22:12
9 verbose stack at _combinedTickCallback (internal/process/next_tick.js:95:7)
9 verbose stack at process._tickCallback (internal/process/next_tick.js:161:9)
10 verbose cwd /home/username
11 verbose Linux 4.11.7-1-ARCH
12 verbose argv "/usr/bin/node" "/usr/bin/npm" "install" "web3"
13 verbose node v8.1.3
14 verbose npm v5.0.4
15 error Path must be a string. Received undefined
16 verbose exit [ 1, true ]
I've tried running them with root user as well.
The problem might come from using a beta version of web3 it's not stable at the moment and currently is under heavy development you have one of two options,
either use a stable version 0.19 I think or something like that.
Another thing I would suggest trying is npm --save in order to save the package locally in the project

Resources