bootstrapping-microservices/chapter-4

Could not npm install azure-storage

baconYao opened this issue · 1 comments

As I mentioned in title, I encountered the error message below while trying npm install --save azure-storage

npm install --save azure-storage
npm ERR! code ENOSELF
npm ERR! Refusing to install package with name "azure-storage" under a package
npm ERR! also called "azure-storage". Did you name your project the same
npm ERR! as the dependency you're installing?
npm ERR! 
npm ERR! For more information, see:
npm ERR!     <https://docs.npmjs.com/cli/install#limitations-of-npms-install-algorithm>

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/baconyao/.npm/_logs/2020-07-25T07_13_56_827Z-debug.log

2020-07-25T07_13_56_827Z-debug.log message

0 info it worked if it ends with ok
1 verbose cli [ '/Users/baconyao/.nvm/versions/node/v10.15.3/bin/node',
1 verbose cli   '/Users/baconyao/.nvm/versions/node/v10.15.3/bin/npm',
1 verbose cli   'install',
1 verbose cli   '--save',
1 verbose cli   'azure-storage' ]
2 info using npm@6.4.1
3 info using node@v10.15.3
4 verbose npm-session fa2dd46620963658
5 silly install loadCurrentTree
6 silly install readLocalPackageData
7 http fetch GET 200 https://registry.npmjs.org/azure-storage 14ms (from cache)
8 silly pacote tag manifest for azure-storage@latest fetched in 25ms
9 timing stage:loadCurrentTree Completed in 163ms
10 silly install loadIdealTree
11 silly install cloneCurrentTreeToIdealTree
12 timing stage:loadIdealTree:cloneCurrentTree Completed in 1ms
13 silly install loadShrinkwrap
14 timing stage:loadIdealTree:loadShrinkwrap Completed in 0ms
15 silly install loadAllDepsIntoIdealTree
16 timing stage:rollbackFailedOptional Completed in 0ms
17 timing stage:runTopLevelLifecycles Completed in 166ms
18 silly saveTree azure-storage@1.0.0
19 verbose stack Error: Refusing to install package with name "azure-storage" under a package
19 verbose stack also called "azure-storage". Did you name your project the same
19 verbose stack as the dependency you're installing?
19 verbose stack
19 verbose stack For more information, see:
19 verbose stack     <https://docs.npmjs.com/cli/install#limitations-of-npms-install-algorithm>
19 verbose stack     at checkSelf (/Users/baconyao/.nvm/versions/node/v10.15.3/lib/node_modules/npm/lib/install/validate-args.js:64:14)
19 verbose stack     at Array.<anonymous> (/Users/baconyao/.nvm/versions/node/v10.15.3/lib/node_modules/npm/node_modules/slide/lib/bind-actor.js:15:8)
19 verbose stack     at LOOP (/Users/baconyao/.nvm/versions/node/v10.15.3/lib/node_modules/npm/node_modules/slide/lib/chain.js:15:14)
19 verbose stack     at /Users/baconyao/.nvm/versions/node/v10.15.3/lib/node_modules/npm/node_modules/slide/lib/chain.js:18:7
19 verbose stack     at hasMinimumFields (/Users/baconyao/.nvm/versions/node/v10.15.3/lib/node_modules/npm/lib/install/validate-args.js:30:12)
19 verbose stack     at Array.<anonymous> (/Users/baconyao/.nvm/versions/node/v10.15.3/lib/node_modules/npm/node_modules/slide/lib/bind-actor.js:15:8)
19 verbose stack     at LOOP (/Users/baconyao/.nvm/versions/node/v10.15.3/lib/node_modules/npm/node_modules/slide/lib/chain.js:15:14)
19 verbose stack     at chain (/Users/baconyao/.nvm/versions/node/v10.15.3/lib/node_modules/npm/node_modules/slide/lib/chain.js:20:5)
19 verbose stack     at /Users/baconyao/.nvm/versions/node/v10.15.3/lib/node_modules/npm/lib/install/validate-args.js:16:5
19 verbose stack     at /Users/baconyao/.nvm/versions/node/v10.15.3/lib/node_modules/npm/node_modules/slide/lib/async-map.js:52:35
19 verbose stack     at Array.forEach (<anonymous>)
19 verbose stack     at /Users/baconyao/.nvm/versions/node/v10.15.3/lib/node_modules/npm/node_modules/slide/lib/async-map.js:52:11
19 verbose stack     at Array.forEach (<anonymous>)
19 verbose stack     at asyncMap (/Users/baconyao/.nvm/versions/node/v10.15.3/lib/node_modules/npm/node_modules/slide/lib/async-map.js:51:8)
19 verbose stack     at module.exports (/Users/baconyao/.nvm/versions/node/v10.15.3/lib/node_modules/npm/lib/install/validate-args.js:15:3)
19 verbose stack     at Array.<anonymous> (/Users/baconyao/.nvm/versions/node/v10.15.3/lib/node_modules/npm/node_modules/slide/lib/bind-actor.js:15:8)
20 verbose cwd /Users/baconyao/PersonalSpace/my-space/stream-service/azure-storage
21 verbose Darwin 17.5.0
22 verbose argv "/Users/baconyao/.nvm/versions/node/v10.15.3/bin/node" "/Users/baconyao/.nvm/versions/node/v10.15.3/bin/npm" "install" "--save" "azure-storage"
23 verbose node v10.15.3
24 verbose npm  v6.4.1
25 error code ENOSELF
26 error Refusing to install package with name "azure-storage" under a package
26 error also called "azure-storage". Did you name your project the same
26 error as the dependency you're installing?
26 error
26 error For more information, see:
26 error     <https://docs.npmjs.com/cli/install#limitations-of-npms-install-algorithm>
27 verbose exit [ 1, true ]

This is strange!

I didn't see this issue using Node.js 12.18.1 and npm 6.14.5.

But I used nvm (Windows, OSX, Linux) to switch to Node.js 10.15.2 and npm 6.4.1 and I can see the problem now.

It looks like a limitation of the older version of npm that has since been fixed.

To work around this you can use nvm to switch to Node.js v12 (and switch back to v10 whenever you need to).

Or you can rename the parent directory from azure-storage to something.

Thanks so much for reporting this issue.

Cheers
Ashley Davis