I am not able to init stencil. I have mentioned below details and if i use sudo npm init stencil installing but not able to edit any files via visual studio.
npm init stencil
Error: EACCES: permission denied, mkdir '/Users/apple/.npm/_npx/2483'
TypeError: Cannot read property 'get' of undefined
at errorMessage (/usr/local/lib/node_modules/npm/lib/utils/error-message.js:38:39)
at errorHandler (/usr/local/lib/node_modules/npm/lib/utils/error-handler.js:201:13)
at /usr/local/lib/node_modules/npm/bin/npm-cli.js:78:20
at cb (/usr/local/lib/node_modules/npm/lib/npm.js:225:22)
at /usr/local/lib/node_modules/npm/lib/npm.js:263:24
at /usr/local/lib/node_modules/npm/lib/config/core.js:81:7
at Array.forEach (
at /usr/local/lib/node_modules/npm/lib/config/core.js:80:13
at f (/usr/local/lib/node_modules/npm/node_modules/once/once.js:25:25)
at afterExtras (/usr/local/lib/node_modules/npm/lib/config/core.js:171:20)
/usr/local/lib/node_modules/npm/lib/utils/error-handler.js:97
var doExit = npm.config.loaded ? npm.config.get('_exit') : true
^
TypeError: Cannot read property 'loaded' of undefined
at exit (/usr/local/lib/node_modules/npm/lib/utils/error-handler.js:97:27)
at process.errorHandler (/usr/local/lib/node_modules/npm/lib/utils/error-handler.js:216:3)
at process.emit (events.js:210:5)
at process._fatalException (internal/process/execution.js:150:25)
Install for [ 'create-stencil@latest' ] failed with code 7
node -v
v12.13.1
npm -v
6.12.1
@rajiramamoorthi I got the same error message when tried to run npm install no the mounted with sshfs file systems. The following command has fixed the problem:
npm i --unsafe-perm <directory where I run npm install>
It's certainly not Stencil's fault if your machine has permissions issues; you'll have the same issues with other libraries with npm init.
For starters, don't use sudo to install modules. EVER. If your user can't access the directory, the proper way to deal with that is groups. "It doesn't work, so I'll try sudo" is a horrible habit. (It's out of scope for here, but google "linux group permissions" for the proper solution to shared directories. Mac works the same way).
However, unless you have a compelling reason to share installed modules between multiple users, I strongly recommend moving the path where npm installs modules inside of your home directory. This prevents any possibility of these sorts of issues
See https://docs.npmjs.com/resolving-eacces-permissions-errors-when-installing-packages-globally
They mention the ~/.profile file, but could also use e.g. ~/.bashrc instead.
Finally, after those steps, you globally install npm itself with npm so it and npx also live in your home dir.
npm install -g npm
Found out my problem was not Stencil in this instance, but issues with permissions between Windows and WSL Debian.
Most helpful comment
@rajiramamoorthi I got the same error message when tried to run
npm installno the mounted with sshfs file systems. The following command has fixed the problem:npm i --unsafe-perm <directory where I run npm install>