Unable to run any child processes with npm - node.js

I'm trying to install packages for a work repo, however whenever I try to run the install, once it gets to the child processes (like running install scripts for a package) I get a weird spawn error. I'm assuming it's having issues running the child processes.
Some information:
Windows machine
Node v12.22.3 and npm v6.14.13 (I've tried node 14)
Tried using bash, windows terminal, cmd prompt, and powershell (all with admin)
Error code seems to be a 4058 but I'm not sure what it can't find
It was working fine just last week, now suddenly I can't get anything done. I've tried the following:
Turning off the Work AV
Removing node_modules and package-lock
Running npm cache clear --force and npm cache verify
Uninstalling node and reinstalling
Completely uninstalling nvm and node and reinstalling
The error I see is:
npm ERR! code ELIFECYCLE
npm ERR! syscall spawn =
npm ERR! file =
npm ERR! path =
npm ERR! errno ENOENT
npm ERR! root# prepare: `husky install`
npm ERR! spawn = ENOENT
npm ERR!
npm ERR! Failed at the root# prepare 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\dhers\AppData\Roaming\npm-cache\_logs\2021-07-19T18_28_56_807Z-debug.log
Do note this is NOT a husky problem, anything that runs a child process script seems to have this error happen.
I've never seen this before and I'm unable to fix it with the googling I've done. Here is some information from the npm log:
59 silly lifecycle root#~prepare: Args: [ '-c', 'husky install' ]
60 info lifecycle root#~prepare: Failed to exec prepare script
61 silly lifecycle root#~prepare: Returned: code: -4058 signal: null
62 info lifecycle root#~prepare: Failed to exec prepare script
63 verbose stack Error: root# prepare: `husky install`
63 verbose stack spawn = ENOENT
63 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:268:19)
63 verbose stack at onErrorNT (internal/child_process.js:470:16)
63 verbose stack at processTicksAndRejections (internal/process/task_queues.js:84:21)
64 verbose pkgid root#
65 verbose cwd C:\Users\dhers\Documents\Development\Work\seamless
66 verbose Windows_NT 10.0.19042
67 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "i"
68 verbose node v12.22.3
69 verbose npm v6.14.13
Has anyone seen this before? I'm really hoping I'm just overlooking something super simple. Any help would be appreciated because this has me halted right now.

Maybe try the following:
Clean the npm cache
npm cache clean --force
Check the npm version you're using. Maybe it should be updated:
npm install -g npm#latest
Try with another version of the package huskey
For this specific scenario, try to skip huskey install through adding
export HUSKY_SKIP_INSTALL=true
to the npm install cmd just to see whether the problem persists with other prepare scripts.
Add the script to the postinstall hook instead of the prepare hook to see if the problem is from the hook.
Go up level by level in your working directory and make sure there are no other directories containing /node_modules directory or package.json or a pakcage-lock.json file. Sometimes npm considers it the root of the project.

Make sure your system environment variables PATH contains the following values:
%SystemRoot%
%SystemRoot%\system32
%SystemRoot%\System32\Wbem
C:\Program Files\nodejs\
Also, make sure your User environment variables PATH contains the following value:
C:\Users\dhers\AppData\Roaming\npm
Note that you need to restart your computer for the changes to take effect.

Delete package-lock.json and node_modules
Execute npm cache clean --force
Execute npm install or yarn install
Then again run
maybe the wrong is your dependencies, check in your package.json
and your npm local is not the correct
"dependencies": {
"npm": "^7.5.6",
then you can try with yarn, yarn install

Related

When upgrading node from 6 to latest, npm i fails with ENOENT in react native project

When upgrading to newer versions of npm from 6.14 to latest on react native project
Using node 14, nvm to switch node versions, ideally i'd like to go to node 16, but a similar issue happens regardless of 14 or 16 when updating npm in particular.
I'm also using homebrew on mac M1
I notice the Jetify command asks me:
Jetifier found 1390 file(s) to forward-jetify. Using 8 workers...
Need to install the following packages:
pod
Ok to proceed? (y)
when i select y, npm i fails. I've cleared cache's and removed node_modules. normal cache clearing attempts don't seem to work.
npm ERR! code ENOENT
npm ERR! syscall chmod
npm ERR! path /Users/user/.npm/_npx/a0ca5f5666585aa2/node_modules/pod/node_modules/pm2/bin/pm2
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, chmod '/Users/user/.npm/_npx/a0ca5f5666585aa2/node_modules/pod/node_modules/pm2/bin/pm2'
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! /Users/user/.npm/_logs/2022-01-28T21_51_28_303Z-debug-0.log
npm ERR! code 254
npm ERR! path /Users/user/repos/MyApp/My-MobileApp
npm ERR! command failed
npm ERR! command sh -c npx jetify && cd ios && npx pod install && cd .. && ./node_modules/.bin/patch-package
Here is part of the complete log -
3325 timing reify:rollback:retireShallow Completed in 0ms
3326 timing command:exec Completed in 42372ms
3327 verbose stack Error: ENOENT: no such file or directory, chmod '/Users/user/.npm/_npx/a0ca5f5666585aa2/node_modules/pod/node_modules/pm2/bin/pm2'
3328 verbose cwd /Users/user/repos/MyApp/MyApp-MobileApp/ios
3329 verbose Darwin 21.2.0
3330 verbose argv "/Users/user/.nvm/versions/node/v14.18.3/bin/node" "/Users/user/.nvm/versions/node/v14.18.3/lib/node_modules/npm/bin/npm-cli.js" "exec" "--" "pod" "install"
3331 verbose node v14.18.3
3332 verbose npm v8.4.0
3333 error code ENOENT
3334 error syscall chmod
3335 error path /Users/user/.npm/_npx/a0ca5f5666585aa2/node_modules/pod/node_modules/pm2/bin/pm2
3336 error errno -2
3337 error enoent ENOENT: no such file or directory, chmod '/Users/user/.npm/_npx/a0ca5f5666585aa2/node_modules/pod/node_modules/pm2/bin/pm2'
3338 error enoent This is related to npm not being able to find a file.
3338 error enoent
3339 verbose exit -2
3340 timing npm Completed in 42533ms
3341 verbose unfinished npm timer reify 1643406718315
3342 verbose unfinished npm timer reify:build 1643406730346
3343 verbose unfinished npm timer build 1643406730346
3344 verbose unfinished npm timer build:deps 1643406730347
3345 verbose unfinished npm timer build:link 1643406730354
3346 verbose unfinished npm timer build:link:node_modules/pod 1643406730356
3347 verbose code -2
3348 error A complete log of this run can be found in:
3348 error /Users/user/.npm/_logs/2022-01-28T21_51_28_303Z-debug-0.log
It looks like the error is related to not finding the pm2 package from pod dependency.
Not sure if this will work properly with npx, you might need to install pod globally to get this working.
npm install pod -g
pod install // instead of npx pod install
https://www.npmjs.com/package/pod#installation
Try npm rebuild they say to use "only when you upgrade the node version and must recompile"
hello i once faced this type of issue and issue was actually because pm2 or some other package or processes on old node which was used in your app wasnt found in the updated node version
Reinstall your pm2 package and other package used by your old node in your code again and try again
let me know if this helps you

after create-react-app failed to start script

Failed at the start script and didn't run nothing, while running the following command:
npm start
The Error
There might be a problem with the project dependency tree.
It is likely not a bug in Create React App, but something you need to fix locally.
The react-scripts package provided by Create React App requires a dependency:
"webpack-dev-server": "3.2.1"
Don't try to install it manually: your package manager does it automatically.
However, a different version of webpack-dev-server was detected higher up in the tree:
/home/akhilbatchu/node_modules/webpack-dev-server (version: 3.8.1)
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 "webpack-dev-server" 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 /home/akhilbatchu/node_modules/webpack-dev-server is outside your project directory.
For example, you might have accidentally installed something in your home folder.
7. Try running npm ls webpack-dev-server in your project folder.
This will tell you which other package (apart from the expected react-scripts) installed webpack-dev-server.
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! appnamsse#0.1.0 start: `react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the appnamsse#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! /home/akhilbatchu/.npm/_logs/2019-11-14T06_22_13_747Z-debug.log
Here is the complete log about what happened:
0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli '/home/akhilbatchu/.nvm/versions/node/v12.13.0/bin/node',
1 verbose cli '/home/akhilbatchu/.nvm/versions/node/v12.13.0/bin/npm',
1 verbose cli 'start'
1 verbose cli ]
2 info using npm#6.12.0
3 info using node#v12.13.0
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info lifecycle appnamsse#0.1.0~prestart: appnamsse#0.1.0
6 info lifecycle appnamsse#0.1.0~start: appnamsse#0.1.0
7 verbose lifecycle appnamsse#0.1.0~start: unsafe-perm in lifecycle true
8 verbose lifecycle appnamsse#0.1.0~start: PATH: /home/akhilbatchu/.nvm/versions/node/v12.13.0/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/home/akhilbatchu/appnamsse/node_modules/.bin:/home/akhilbatchu/.nvm/versions/node/v12.13.0/bin:/home/akhilbatchu/anaconda3/bin:/home/akhilbatchu/anaconda3/condabin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/usr/lib/jvm/java-8-oracle/bin:/usr/lib/jvm/java-8-oracle/db/bin:/usr/lib/jvm/java-8-oracle/jre/bin
9 verbose lifecycle appnamsse#0.1.0~start: CWD: /home/akhilbatchu/appnamsse
10 silly lifecycle appnamsse#0.1.0~start: Args: [ '-c', 'react-scripts start' ]
11 silly lifecycle appnamsse#0.1.0~start: Returned: code: 1 signal: null
12 info lifecycle appnamsse#0.1.0~start: Failed to exec start script
13 verbose stack Error: appnamsse#0.1.0 start: `react-scripts start`
13 verbose stack Exit status 1
13 verbose stack at EventEmitter.<anonymous> (/home/akhilbatchu/.nvm/versions/node/v12.13.0/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:332:16)
13 verbose stack at EventEmitter.emit (events.js:210:5)
13 verbose stack at ChildProcess.<anonymous> (/home/akhilbatchu/.nvm/versions/node/v12.13.0/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack at ChildProcess.emit (events.js:210:5)
13 verbose stack at maybeClose (internal/child_process.js:1021:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:283:5)
14 verbose pkgid appnamsse#0.1.0
15 verbose cwd /home/akhilbatchu/appnamsse
16 verbose Linux 4.15.0-64-generic
17 verbose argv "/home/akhilbatchu/.nvm/versions/node/v12.13.0/bin/node" "/home/akhilbatchu/.nvm/versions/node/v12.13.0/bin/npm" "start"
18 verbose node v12.13.0
19 verbose npm v6.12.0
20 error code ELIFECYCLE
21 error errno 1
22 error appnamsse#0.1.0 start: `react-scripts start`
22 error Exit status 1
23 error Failed at the appnamsse#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 ]
Versions:
Node: v12.13.0
NPM: v6.12.0
Environment
react: "^16.11.0",
react-dom: "^16.11.0",
react-scripts: "3.2.0"
Could anyone please help me as I am not able to figure out what is going wrong and completely new to react.
Thank you.
Have you installed the dependencies .
npm install
If it doesn't work delete the node_modules folder from project. then
npm install
npm start
Did you read the first error message?
It says (step 6) you have (accidentally, probably) installed a copy of webpack-dev-server into your home directory
/home/akhilbatchu/node_modules/webpack-dev-server
Get rid of that copy (for instance, rename /home/akhilbatchu/node_modules into /home/akhilbatchu/node_modules_unused if you don't want to outright remove it), then try again.
I did followed this steps to work
npm install -g npm#latest it'll update npm, in case your modules are not updated
rm -rf node_modules
Delete node_modules in your project folder. as mentioned in the log
npm install
Run npm install or yarn, depending on the package manager you use. as it is mentioned in the console

sh: 1: cross-env: Permission denied on laravel mix

I'm trying to run npm run dev but the following error occur:
sh: 1: cross-env: Permission denied
npm ERR! code ELIFECYCLE
npm ERR! errno 126
npm ERR! # development: `cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js`
npm ERR! Exit status 126
npm ERR!
npm ERR! Failed at the # development 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/shanmaseen/.npm/_logs/2019-02-22T16_32_08_191Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 126
npm ERR! # dev: `npm run development`
npm ERR! Exit status 126
npm ERR!
npm ERR! Failed at the # 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! /home/shanmaseen/.npm/_logs/2019-02-22T16_32_08_241Z-debug.log
I've been searching the internet for a week, nothing helped at all !
I even tried to remove 'cross-env' from package.json scripts, but then webpack: permission denied happened, indicating that the permission error is not by cross-env it self.
this is the error log:
0 info it worked if it ends with ok
1 verbose cli [ '/usr/bin/node', '/usr/bin/npm', 'run', 'dev' ]
2 info using npm#6.7.0
3 info using node#v11.10.0
4 verbose run-script [ 'predev', 'dev', 'postdev' ]
5 info lifecycle #~predev: #
6 info lifecycle #~dev: #
7 verbose lifecycle #~dev: unsafe-perm in lifecycle true
8 verbose lifecycle #~dev: PATH: /usr/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/media/e/www/mwar/node_modules/.bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
9 verbose lifecycle #~dev: CWD: /media/e/www/mwar
10 silly lifecycle #~dev: Args: [ '-c', 'npm run development' ]
11 silly lifecycle #~dev: Returned: code: 126 signal: null
12 info lifecycle #~dev: Failed to exec dev script
13 verbose stack Error: # dev: `npm run development`
13 verbose stack Exit status 126
13 verbose stack at EventEmitter.<anonymous> (/usr/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:301:16)
13 verbose stack at EventEmitter.emit (events.js:197:13)
13 verbose stack at ChildProcess.<anonymous> (/usr/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack at ChildProcess.emit (events.js:197:13)
13 verbose stack at maybeClose (internal/child_process.js:984:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:265:5)
14 verbose pkgid #
15 verbose cwd /media/e/www/mwar
16 verbose Linux 4.18.0-15-generic
17 verbose argv "/usr/bin/node" "/usr/bin/npm" "run" "dev"
18 verbose node v11.10.0
19 verbose npm v6.7.0
20 error code ELIFECYCLE
21 error errno 126
22 error # dev: `npm run development`
22 error Exit status 126
23 error Failed at the # dev script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 126, true ]
I'm using laravel 5.7mix.
node version: v11.10.0
npm version: 6.7.0
any help please?
I was on ubuntu 18.
Following command helped me :-)
npm rebuild
Documented as follows, on the official website.
This command runs the npm build command on the matched folders. This is useful when you install a new version of node, and must recompile all your C++ addons with the new binary. It is also useful when installing with --ignore-scripts and --no-bin-links, to explicitly choose which packages to build and/or link bins.
If one or more package names (and optionally version ranges) are provided, then only packages with a name and version matching one of the specifiers will be rebuilt.
This is because of permission issues with global installation of packages, which npm is being denied access.
To solve this try
1.
npm rebuild
npm run watch
Or 2
rm -Rf node_modules
npm install
npm run watch
Hope it works.
The following thing worked for me
chmod -R a+x node_modules
source
If file and/or directory permissions were changed to more restrictive ones, a permission error like the following can happen on Ubuntu Linux:
$ npm run watch
> watch
> mix watch
sh: 1: mix: Permission denied
to resolve that on Ubuntu Linux, this worked for me:
chmod -R u+x node_modules
It gives+ you as useru executionx permission recursively -R to the node_modules directory and everything inside it.
Be careful, think about security and do not use the a, o nor the g flag instead of the u flag, which would give all, others or group execution rights. The g flag might be ok, if you trust all the users in the group.
As ruuter states in comments, it would be even better for security, if you find the exact file(s) that need execution permission and grant execution permission only for these files.
As #savedbeau suggests, running the following fixes this problem:
npm rebuild
followed by
npm run watch
Try this.
$ rm -rf node_modules
$ npm cache clear --force
$ npm install npm#latest -g
$ chown -R $USER ~/.npm
$ npm install
Ok I figure out the problem, the storage where the project is saved is auto-mounted and it have no execution permission.
easily in /etc/fstab file i added exec in the mount option, like this:
auto,user,exec,utf8,uid=1000,gid=1000,rw 0 0

getting error while running any npm command [duplicate]

In my server(CentOS 7.2) I install the dependencies:
npm install
But I get bellow error:
npm ERR! code Z_BUF_ERROR
npm ERR! errno -5
npm ERR! unexpected end of file
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2018-02-11T21_03_20_261Z-debug.log
in the /root/.npm/_logs/2018-02-11T21_03_20_261Z-debug.log, the info is bellow:
10234 verbose bundle EBUNDLEOVERRIDE: Replacing npm#1.4.29's bundled version of readable-stream with readable-stream#1.0.34.
10235 verbose unlock done using /root/.npm/_locks/staging-ace74a3b0cf47932.lock for /home/ubuntu/source_code_web/vue_admin_site/node_modules/.staging
10236 warn The package iview is included as both a dev and production dependency.
10237 warn npm#1.4.29 had bundled packages that do not match the required version(s). They have been replaced with non-bundled versions.
10238 verbose type OperationalError
10239 verbose stack Error: unexpected end of file
10239 verbose stack at Gunzip.zlibOnError (zlib.js:152:15)
10240 verbose cwd /home/ubuntu/source_code_web/vue_admin_site
10241 verbose Linux 3.10.0-327.el7.x86_64
10242 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "install"
10243 verbose node v8.4.0
10244 verbose npm v5.3.0
10245 error code Z_BUF_ERROR
10246 error errno -5
10247 error unexpected end of file
10248 verbose exit [ -5, true ]
I tried useļ¼š
npm cache clean
to clean the npm, but fails:
npm ERR! As of npm#5, the npm cache self-heals from corruption issues and data extracted from the cache is guaranteed to be valid. If you want to make sure everything is consistent, use 'npm cache verify' instead.
npm ERR!
npm ERR! If you're sure you want to delete the entire cache, rerun this command with --force.
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2018-02-11T21_13_51_943Z-debug.log
Try cleaning the cache with the command npm cache clean --force and retry your npm install.
"npm cache clean --force"
"npm cache verify"
following steps helped me!! :-)
if problem still persist : "npm i npm"
In the end, I delete the node_modules:
rm -rf node_modules
and deleted the package-lock.json,
then re-install:
npm install
It works for me.
As suggested in npm GitHub
Node 8.9.0+ (and 9+) fix an issue where streams are terminated early
in some scenarios. If you're getting this error upgrade to 8.9.
So you can just try to update your node and npm
I was trying this on Windows 10 and the only solution that worked for me was updating npm by giving
npm install npm#latest -g
None of the listed solutions helped in my case. I solved the problem by manually removing the caches folder:
rm -rf ~/.npm/_cacache
Or if npm installed in the root folder:
sudo rm -rf /root/.npm/_cacache
npm install --cache /tmp/empty-cache
This is what worked for me
The network caused the module to download the failure
Install a Taobao image and then it's fine:
npm install -g cnpm -- registry-https://registry.npm.taobao.org
cnpm install egg -- save
After trying everything related to npm still the problem persist then it might be caused due to some unwanted cache which are getting deleted in the ".apm" folder.
Follow these steps.
Goto -> C:\Users\Your_Username\.atom\.apm\_cacache
Delete all the files(tmp,content,index etc..)
Again try and install the package by command or atom.
This might work for you. :-)

nodejs npm package | npm link issue

I am trying to make a npm package (plugin) to install the little JS framework through node, have come up with the required package.json as well.
After running the npm link command on Mac terminal, got to see the following errors.
npm ERR! Error: EACCES, symlink '/Repos/GIT/JavaScript-Boilerplate'
npm ERR! { [Error: EACCES, symlink '/Repos/GIT/JavaScript-Boilerplate']
npm ERR! errno: 3,
npm ERR! code: 'EACCES',
npm ERR! path: '/Repos/GIT/JavaScript-Boilerplate' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
npm ERR! System Darwin 12.3.0
npm ERR! command "node" "/usr/local/bin/npm" "link"
npm ERR! cwd /Repos/GIT/JavaScript-Boilerplate
npm ERR! node -v v0.10.4
npm ERR! npm -v 1.2.18
npm ERR! path /Repos/GIT/JavaScript-Boilerplate
npm ERR! code EACCES
npm ERR! errno 3
npm ERR! stack Error: EACCES, symlink '/Repos/GIT/JavaScript-Boilerplate'
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /Repos/GIT/JavaScript-Boilerplate/npm-debug.log
npm ERR! not ok code 0
P.S. I am pretty new to nodejs but have strong experience in JavaScript, let me know if you need more detail around.
EDIT - Got to resolved the issues given above but now getting more issues as below:
6495 verbose false,/Repos/GIT/JavaScript-Boilerplate/node_modules,/Repos/GIT/JavaScript-Boilerplate/node_modules/jquery/node_modules unbuild contextify#0.1.5
6496 info postuninstall contextify#0.1.5
6497 verbose about to build /Repos/GIT/JavaScript-Boilerplate/node_modules/jquery
6498 info /Repos/GIT/JavaScript-Boilerplate/node_modules/jquery unbuild
6499 verbose from cache /Repos/GIT/JavaScript-Boilerplate/node_modules/jquery/package.json
6500 info preuninstall jquery#1.8.3
6501 info uninstall jquery#1.8.3
6502 verbose true,/Repos/GIT/JavaScript-Boilerplate/node_modules,/Repos/GIT/JavaScript-Boilerplate/node_modules unbuild jquery#1.8.3
6503 info postuninstall jquery#1.8.3
6504 error contextify#0.1.5 install: `node-gyp rebuild`
6504 error `sh "-c" "node-gyp rebuild"` failed with 1
6505 error Failed at the contextify#0.1.5 install script.
6505 error This is most likely a problem with the contextify package,
6505 error not with npm itself.
6505 error Tell the author that this fails on your system:
6505 error node-gyp rebuild
6505 error You can get their info via:
6505 error npm owner ls contextify
6505 error There is likely additional logging output above.
6506 error System Darwin 12.3.0
6507 error command "node" "/usr/local/bin/npm" "link"
6508 error cwd /Repos/GIT/JavaScript-Boilerplate
6509 error node -v v0.10.4
6510 error npm -v 1.2.18
6511 error code ELIFECYCLE
6512 verbose exit [ 1, true ]
enter code here
enter code here
Looks like I am close to it :)
Permissions you used when installing Node will be required when doing things like writing in your npm directory (npm link, npm install -g, etc.).
You probably ran node installation with root permissions, that's why the global package installation is asking you to be root.
Solution 1: NVM
Don't hack with permissions, install node the right way.
On a development machine, you should not install and run node with root permissions, otherwise things like npm link, npm install -g will need the same permissions.
NVM (Node Version Manager) allows you to install Node without root permissions and also allows you to install many versions of Node to play easily with them.. Perfect for development.
Uninstall Node (root permission will probably be required).
To remove all previously installed npm global modules, see those answers.
Then install NVM following instructions on this page.
Install Node via NVM: nvm install stable
Now npm link, npm install -g will no longer require you to be root.
Solution 2: Install packages globally for a given user
Don't hack with permissions, install npm packages globally the right way.
If you are on OSX or Linux, you can create a user dedicated directory for your global package and setup npm and node to know how to find globally installed packages.
Check out this great article for step by step instructions on installing npm modules globally without sudo.
See also: npm's documentation on Fixing npm permissions.
The easiest way to solve this would be to run the same command again using sudo:
sudo npm link
Please don't change the owner of the /usr/local directory, as this might a) have further implications on installed application and b) might compromise the security on your system. Using sudo is the right way to solve this.
This can be fixed in linux or in my case WSL by setting the global package directory to be in user space rather than root.
First create a dir for global packages
mkdir ~/.npm-packages
Then tell npm where to store globally installed packages
npm config set prefix ~/.npm-packages
Finally ensure npm will find installed binaries and man pages by adding the following to your .bashrc/.zshrc:
NPM_PACKAGES=~/.npm-packages
export PATH="$PATH:$NPM_PACKAGES/bin"
# Preserve MANPATH if you already defined it somewhere in your config.
# Otherwise, fall back to `manpath` so we can inherit from `/etc/manpath`.
export MANPATH="${MANPATH-$(manpath)}:$NPM_PACKAGES/share/man"

Resources