npm install fails with EACCES: permission denied - node.js

I am trying to install Node.js on a Debian 9 (Stretch) box. Initially I run the following commands as root:
curl -Lo node.tar.xz https://nodejs.org/dist/v10.15.0/node-v10.15.0-linux-x64.tar.xz
echo "4ee8503c1133797777880ebf75dcf6ae3f9b894c66fd2d5da507e407064c13b5 node.tar.xz" | sha256sum -c -
tar xJf node.tar.xz
cp -a node-v10.15.0-linux-x64/. /usr/local/
Next I run npm install, from the source dir of the project I am trying to build, with a regular user account, and get the following error:
> git-validate#2.2.2 install /blah/node_modules/git-validate
> node bin/install
fs.js:115
throw err;
^
Error: EACCES: permission denied, open '/blah/.git/hooks/pre-commit'
at Object.openSync (fs.js:439:3)
at Object.writeFileSync (fs.js:1190:35)
at Object.exports.installHooks (/blah/node_modules/git-validate/lib/utils.js:248:12)
at Object.<anonymous> (/blah/node_modules/git-validate/bin/install.js:3:7)
at Module._compile (internal/modules/cjs/loader.js:689:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
at Module.load (internal/modules/cjs/loader.js:599:32)
at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
at Function.Module._load (internal/modules/cjs/loader.js:530:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:742:12)
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents#1.2.4 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents#1.2.4: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! git-validate#2.2.2 install: `node bin/install`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the git-validate#2.2.2 install 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! /root/.npm/_logs/2019-01-20T19_55_48_025Z-debug.log
The source dir is a git repo cloned under the same user account which is now running npm install.
What am I doing wrong?

Related

npm start at reboot doesn't handle destructuring operator (Beaglebone on Debian)

I have a node app that runs nicely from the command line with a npm start command
But when I start it from the crontab #reboot issues the following error:
> pepsr#1.0.104 start /home/debian/Desktop/devel/iot
> node pepsr.js
/home/debian/Desktop/devel/iot/pepsr.js:206
...config
^^^
SyntaxError: Unexpected token ...
at createScript (vm.js:56:10)
at Object.runInThisContext (vm.js:97:10)
at Module._compile (module.js:549:28)
at Object.Module._extensions..js (module.js:586:10)
at Module.load (module.js:494:32)
at tryModuleLoad (module.js:453:12)
at Function.Module._load (module.js:445:3)
at Module.runMain (module.js:611:10)
at run (bootstrap_node.js:394:7)
at startup (bootstrap_node.js:160:9)
npm ERR! Linux 4.14.108-ti-r113
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "start"
npm ERR! node v6.17.0
npm ERR! npm v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! pepsr#1.0.104 start: `node pepsr.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the pepsr#1.0.104 start script 'node pepsr.js'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the pepsr package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node pepsr.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs pepsr
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls pepsr
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /home/debian/Desktop/devel/iot/npm-debug.log
My cron tab is as follows:
#reboot sleep 180 && /home/debian/Desktop/devel/iot/pepsrRestartOnReboot.sh
pepsrRestartOnReboot.sh is as follows:
cd /home/debian/Desktop/devel/iot/
./pepsrStart.sh &
pepsrStart.sh is as follows:
cd /home/debian/Desktop/devel/iot/
nohup ./pepsrRestart.sh >> pepsr.log 2>&1
And pepsrRestart.sh is as follows:
npm start
Two version of node was installed.
What I did:
Uninstalled n:
$ sudo n uninstall
Installed node from the NodeSource:
curl -sL https://deb.nodesource.com/setup_12.x | sudo bash -
Actually install node 12 lts:
sudo apt install nodejs
Check that I have what I want:
node -v
v12.22.0

Deployment fails while installing node-sass on Azure linux web app

I'm trying to deploy a website to Azure App Service running Linux, but the deployment fails. The issue seems to be with installing node-sass.
I've set Node to the most recent version that the service supports.
> node-sass#4.11.0 install /home/site/wwwroot/node_modules/node-sass
> node scripts/install.js
fs.js:126
throw err;
^
Error: EINVAL: invalid argument, open '/home/site/wwwroot/node_modules/node-sass/package.json'
at Object.fs.openSync (fs.js:559:3)
at Object.fs.readFileSync (fs.js:465:33)
at Object.Module._extensions..json (internal/modules/cjs/loader.js:695:20)
at Module.load (internal/modules/cjs/loader.js:589:32)
at tryModuleLoad (internal/modules/cjs/loader.js:528:12)
at Function.Module._load (internal/modules/cjs/loader.js:520:3)
at Module.require (internal/modules/cjs/loader.js:626:17)
at require (internal/modules/cjs/helpers.js:20:18)
at Object.<anonymous> (/home/site/wwwroot/node_modules/node-sass/lib/extensions.js:7:9)
at Module._compile (internal/modules/cjs/loader.js:678:30)
npm WARN ppi-web#1.0.0 No repository field.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents#1.2.4 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents#1.2.4: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! node-sass#4.11.0 install: `node scripts/install.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the node-sass#4.11.0 install 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! /home/.npm/_logs/2019-02-07T18_09_48_891Z-debug.log
Running "/opt/nodejs/10.1.0/bin/node" "/opt/npm/6.0.1/node_modules/npm/bin/npm-cli.js" run-script build
I followed this guide. After scaffolding express application, I pushed the code to a github repo and used the Azure Extensions in VS Code to configure the deployment source to my recently create github repo and succeeded.
I'm not exactly sure how you deployed but hopefully this will help. Unfortunately I don't have enough reputation points to ask how you went about deploying but please feel free to let me know.

Error: Cannot find module 'AsyncDependencyToInitialChunkWarning'

I have succesfully installed and deployed to my Debian production server a react app using "create-react-app". I've then pushed it to my repo and pulled it on my development computer (Win10). Here's the output for npm install && npm start
C:\Users\Shad\shadfront>npm install
[ ...........] / extract:webpack-manifest-plugin: verb lock using C:\Users\Shad\AppDat
[ ...........] / extract:webpack-manifest-plugin: verb lock using C:\Users\Shad\AppDa
[ ...........] / extract:webpack-manifest-plugin: verb lock using C:\Users\Shad\AppD
[ ...........] / extract:webpack-manifest-plugin: verb lock using C:\Users\Shad\AppData[ ...........] / extract
:webpack-manifest-plugin: verb lock using C:\Users\Shad\A[ ...........] / extract:webpack-manifest-plugin: verb lock
using C:\Users\Shad\A[ .npm WARN ajv-keywords#3.2.0 requires a peer of ajv#^6.0.0 but none is installed. You must ins
tall peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents#1.2.4 (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents#1.2.4: wanted {"os":"darwin","arch":"any"}
(current: {"os":"win32","arch":"x64"})
added 755 packages in 21.316s
C:\Users\Shad\shadfront>npm start
> shadfront#0.1.0 start C:\Users\Shad\shadfront
> node scripts/start.js
module.js:549
throw err;
^
Error: Cannot find module './AsyncDependencyToInitialChunkWarning'
at Function.Module._resolveFilename (module.js:547:15)
at Function.Module._load (module.js:474:25)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (C:\Users\Shad\shadfront\node_modules\webpack\lib\Compilation.js:23:46)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! shadfront#0.1.0 start: `node scripts/start.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the shadfront#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\Shad\AppData\Roaming\npm-cache\_logs\2018-07-17T14_10_23_162Z-debug.log
What should I do in order to have my React app working on my Win10 ?
Thanks
For anyone ending up here, I've managed to fix this problem by removing my .gitiginore and commiting again.

NPM while starting it shows Cannot find module 'safe-buffer'

I am trying to create a Node Restful API service, but npm is giving me an error while starting. In command prompt I have typed the following :
D:\xampp\htdocs\todoListApi>npm run start
todolistapi#1.0.0 start D:\xampp\htdocs\todoListApi
nodemon server.js
It shows following error
[nodemon] 1.17.3
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: *.*
[nodemon] starting `node server.js`
internal/modules/cjs/loader.js:550
throw err;
^
Error: Cannot find module 'safe-buffer'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:548:15)
at Function.Module._load (internal/modules/cjs/loader.js:475:25)
at Module.require (internal/modules/cjs/loader.js:598:17)
at require (internal/modules/cjs/helpers.js:11:18)
at Object.<anonymous> (D:\xampp\htdocs\todoListApi\node_modules\readable-str
eam\lib\_stream_readable.js:55:14)
at Module._compile (internal/modules/cjs/loader.js:654:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:665:10)
at Module.load (internal/modules/cjs/loader.js:566:32)
at tryModuleLoad (internal/modules/cjs/loader.js:506:12)
at Function.Module._load (internal/modules/cjs/loader.js:498:3)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! todolistapi#1.0.0 start: `nodemon server.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the todolistapi#1.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional log
ging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\admin\AppData\Roaming\npm-cache\_logs\2018-04-20T06_50_15_
033Z-debug.log
D:\xampp\htdocs\todoListApi>npm install mongoose --sav
npm WARN todolistapi#1.0.0 No repository field.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents#1.1.3 (node_modules\fse
vents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents#
1.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"}
Instead it should start npm and show result as
todo list RESTful API server started on: 3000
Please guide me on how I can overcome this.
Try using npm cache clean --force and if it still doesn't work, try to fully re-install NPM/Node :)
The following steps worked for me :
Uninstall Node.js from Control Panel
Go C:/Users/Admin/AppData/Roaming
Delete npm and npm-cache manually
Try installing node.js again.

Error when running vuetifyjs template

I have successfully installed a vuetifyjs template using the command
vue init vuetifyjs/webpack-advanced
it was successfully installed but when I tried to use the command npm run dev I had the following error message:
C:\Users\Muse\Documents\vuetify>npm run dev
vuetify#1.0.0 dev C:\Users\Muse\Documents\vuetify
node build/dev-server.js
fs.js:1657
binding.lstat(baseLong);
^
Error: ENOENT: no such file or directory, lstat 'C:\Users\Muse\Documents\vuetify\test'
at Object.realpathSync (fs.js:1657:15)
at resolve (C:\Users\Muse\Documents\vuetify\build\webpack.base.conf.js:8:13)
at Object. (C:\Users\Muse\Documents\vuetify\build\webpack.base.conf.js:35:35)
at Module._compile (module.js:573:30)
at Object.Module._extensions..js (module.js:584:10)
at Module.load (module.js:507:32)
at tryModuleLoad (module.js:470:12)
at Function.Module._load (module.js:462:3)
at Module.require (module.js:517:17)
at require (internal/module.js:11:18)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! vuetify#1.0.0 dev: node build/dev-server.js
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the vuetify#1.0.0 dev 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\Muse\AppData\Roaming\npm-cache_logs\2017-08-31T09_19_06_701Z-debug.log
You just need to create a test folder and give it access.
It's a bug with webpack-advanced template
Fore install your project dependencies
npm install -f
Then, make a folder named "test" in your root project
mkdir test
It's a bug caused by vuetifyjs/webpack-advanced

Resources