I am installing graphcool locally on my Mac which I think has gone ok:
$ sudo npm install -g graphcool
npm WARN deprecated jsonstream#1.0.3: use JSONStream instead
npm WARN deprecated graceful-fs#3.0.11: please upgrade to graceful-fs 4 for compatibility with current and future versions of Node.js
/usr/local/bin/graphcool-framework -> /usr/local/lib/node_modules/graphcool/dist/index.js
/usr/local/bin/gcf -> /usr/local/lib/node_modules/graphcool/dist/index.js
+ graphcool#0.11.4
updated 1 package in 7.251s
But the graphcool doesn't seem to be recognized:
$ graphcool init server
-bash: graphcool: command not found
I get the same error from graphcool init.
Can anyone help me?
Seems like they changed the binary name from graphcool to graphcool-framework and gcf
https://github.com/graphcool/framework/commit/5de2334440c55f6a42f6d75ad1b06a8d320d5e40
Try:
graphcool-framework init
If you get an error saying "no such file or directory, lstat '~/.graphcool'", do
touch ~/.graphcool
Then retype the init command above
The order in which I set up graphcool was:
npm install -g graphcool-framework
mkdir ~/.graphcool
cd .graphcool
touch config.yml
graphcool-framework init server
Related
Browser Sync is not launching live server after installing node/npm as a root user. Backstory: I tried installing Browser Sync npm to no avail then i installed the npm package and got a permissions error so i installed via the root and it installed. I switched to my regular user acct and tried to launch browser sync to no avail i assumed it would run b/c npm or node was a globe install. While in my regular user account, i ran npm install -g browser-sync
in the terminal again, however im still having permissions issues.
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/browser-sync
I'm using sublime 3 on a mac. Also, i tried using browser sync w/o installing npm to no avail any suggestions would be appreciated, even another tool recommendation.
Change the golbal insall directory using npm config command.
mkdir ~/.npm-global
npm config set prefix '~/.npm-global'
export PATH=~/.npm-global/bin:$PATH
More info: http://npm.github.io/installation-setup-docs/installing/a-note-on-permissions.html
Tried to run this command on ubuntu 18.04
npm install -g pngquant-bin
but I got this error,
[..................] | fetchMetadata: sill resolveWithNewModule npm-conf#1.1.3 checking installable status
npm WARN deprecated gulp-util#3.0.8: gulp-util is deprecated - replace it, following the guidelines at https://medium.com/gulpjs/gulp-util-ca3b1f9f9ac5
/root/.nvm/versions/node/v10.8.0/bin/pngquant -> /root/.nvm/versions/node/v10.8.0/lib/node_modules/pngquant-bin/cli.js
> pngquant-bin#5.0.0 postinstall /root/.nvm/versions/node/v10.8.0/lib/node_modules/pngquant-bin
> node lib/install.js
sh: 1: node: Permission denied
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! pngquant-bin#5.0.0 postinstall: `node lib/install.js`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the pngquant-bin#5.0.0 postinstall 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/2018-08-12T18_08_02_197Z-debug.log
Do you do you know how to deal with this?
I tried every solution found in this articles yet not succeeded.
Got the same error sh: 1: node: Permission denied
So this worked for me
npm config set user 0
npm config set unsafe-perm true
These issues happen because of broken packages. Go to the main folder. If using Linux use command
sudo rm -rf node_modules.
After that run this command if you are using yarn
yarn install
If you are using npm run this command
npm install
Delete the node_modules and install it again
sudo rm -rf node_modules
npm install
in fact, npm can't use root account to install anything. if you use root account, npm will create a non-permission account to install. in this case, if the package need to execute writeFile or other operation which need permission, the error node: Permission denied will be raised.
so, you can choose optional arbitrary under:
npm install xxx --unsafe-perm
npm config set unsafe-perm true
create high-permission account dedicate to execute npm install
In my case it was a silly typo, I was forgotten to add node into the front of the start command in package.json. So I've changed:
"scripts": {
"start": "app/server.js"
}
... to:
"scripts": {
"start": "node app/server.js"
}
The /root/.npm/... log path in your original message shows you're already running as root, and (despite what others advise) I'd say this is most likely causing your problem.
My (limited) experience running Node as root is that most npm install runs get quite a long way, but then fail with some variation on the error you showed. The only reliable solution I've found is to not run Node or npm as root at all on Ubuntu. Just use a normal user account to download and unpack the Node installation.
At least one problem with running as root for me turned out to be because some dependency-of-a-dependency npm install script was calling setuid to switch to a less-privileged user. For some reason, it chose UID 500—which doesn't exist on Ubuntu—and consequently lost all its privileges. The 'Permission denied' errors were therefore because I was running as root; setuid doesn't work for a normal user.
I believe this is related to Error: setuid user id does not exist npm ERR! when npm install forever -g.
Solved my problem chmod -R a+x node_modules
As far as my understanding goes the os is blocking your ability to execute commands described in node_modules so by my understanding what this command does is say everything in node_modules is okay to execute.
By the time I found the solution it was 4 AM, so I didn't really bother to figure out what I actually did. If someone knows what -R a+x node_modules does exactly feel free to drop it in the commands and I will make an edit.
I make the chown to project user owner (in USERID) dir and resolv the "permission denied" problem:
sudo chown -R USERID.USERID *
Additionally (and this might be useful for docker) you can override this configuration setting globally via the environment variable npm_config_user -- for example:
ENV npm_config_user=root
I ran into the same error an nothing really helped. I found a medium article explaining how to set up an angular build management. For some reason adding
- npm link #angular/cli#13.2.5
to my build script made it. I basically added all of the recommendations above. So my build script now looks like this
- ...
- npm config set user 0
- npm config set unsafe-perm true
- npm i --force
- npm link #angular/cli#13.2.5
- ...
I hope it helps! I would be happy if someone could explain why it actually worked.
This is an old question but maybe someone still need some help.
This errors often is displayed because you have defined in the package.json just the path. For example:
{
// more definitions
"scripts": {
// other scripts
"getPax8Products": "<filepath>",
// more scripts
},
// more definitions
}
In this case, you need to:
Add the following lines in the very beggining of the script
#!/usr/bin/env node
'use strict';
Give the file execution permission
# in UNIX based
chmod +x <filepath>
You also can modify the package.json and add the node command. However, you need to be aware that NPM will run in the script's directory:
{
// more definitions
"scripts": {
// other scripts
"getPax8Products": "node <filepath>",
// more scripts
},
// more definitions
}
For Deploying with Docker:
make sure /node_modules is deleted or added to dockerignorefile
make sure /dist is deleted or added to dockerignorefile
the problem was solved for me by deleting both files
and build them in the container
For me, I had not installed my dependencies. node_modules did not exist, but I had jest installed globally apparently. Running npm ci and then running npm test solved my issue.
npm install lite-server --save-dev
packages.json:
"scripts": {
"dev": "lite-server",
},
"devDependencies": {
"lite-server": "^2.6.1"
}
npm run dev
I stuck with same issue when tried to install packages into AWS Sagemaker instance
The issue coming because NPM by default install new global packages into ~/.npm-global
When you run npm install -g by root, npm is try to install package into /root/.npm-global/..., and stuck with access denied.
Simply workaround to re-config global folder for npm.
(https://docs.npmjs.com/resolving-eacces-permissions-errors-when-installing-packages-globally)
Here is example of install obj2gltf
mkdir /npm-global
npm config set prefix '/npm-global'
export PATH=/npm-global/bin:$PATH
npm install -g obj2gltf
I had that error too and tried the above solutions without any change. My error was caused because I had Windows (11) with a WSL and NVM installed on both operating systems. I had to uninstall NVM on my Windows to resolve the conflicts.
I think if you develop in your WSL and have a resource installed on both operating systems, a dependency might point to the wrong operating system with the resource (in my case to the NVM on Windows). The WSL user didn't have sufficient permissions to perform any execution on the Windows machine, which lead to the error.
you need root user permission, just add sudo keyword before the command and write your password
sudo npm install -g pngquant-bin
Try to install node at project folder
npm install node
I have to run npm install --prefix ./ --save bootstrap jquery for it to save in the node_modules. I expect from what I've read in tutorials and such this is not the expected behavior. When I just run npm install --save bootstrap it puts the files into /home/philip/.npm directory as /home/philip/.npm/bootstrap.
npm root gives the correct [project]/node_modules directory.
NPM Version: 3.10.10
Node Version: 6.10.3
OS: Ubuntu 17.04
Edit: Forgot to ask the question, how do I ensure npm install defaults to the project's node_modules directory?
It might be because global flag is set to true somewhere in npm config or via an environment variable.
To check current value run: npm config ls -l | grep global. To change it try to add global=false to your ~/.npmrc file. Also, check the value of $NPM_CONFIG_GLOBAL, it has higher priority than .npmrc.
I'm trying to setup Angular 2 using "npm install #angular/cli -g "
After the install, the only warning I see is the UNMET PEER DEPENDENCY rxjs#^5.0.1, which I then install and reinstall "npm install #angular/cli -g"
No matter what I do, or what version of Node I setup with n, I keep getting the following message when trying to user the "ng" commands:
zsh: command not found: ng
I've been looking around and have not found a solution for this.
Has anyone run into this and have any suggestions?
UPDATE:
It looks like this is not a angular/cli specific issue.
I now see that I get the same message when I try to run "Grunt" and "Ionic" commands on an existing project that was working fine.
zsh: command not found: ionic
zsh: command not found: grunt
Most likely, the directory in which the global modules are installed is not in your $PATH -- and therefore unknown to your shell.
To fix this issue, we can create a new directory for global node_modules, configure npm to use it, and add that directory to your $PATH.
# create a new directory where npm will install packages
$ mkdir ~/.node_modules
# set npm "prefix" config to that directory
$ npm config set prefix '~/.node_modules'
# append a line to your .zshrc instructing it to include that directory in your $PATH, making the executables known to the shell
$ echo 'export PATH=~/.node_modules/bin:$PATH' >> ~/.zshrc
# update current shell with new path (not needed for new sessions)
$ source ~/.zshrc
Then, first reinstall the latest npm (npm i -g npm), followed by the global packages you need (npm i -g #angular/cli).
For more on PATH, see this definition: http://www.linfo.org/path_env_var.html
I wrote a module which I published to npm a moment ago (https://npmjs.org/package/wisp)
So it installs fine from the command line:
$ npm i -g wisp
However, when I run it from the command line, I keep getting an error that optimist isn't installed:
$ wisp
Error: Cannot find module 'optimist'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:362:17)
at require (module.js:378:17)
at Object.<anonymous> (/usr/local/lib/node_modules/wisp/wisp:12:10)
at Object.<anonymous> (/usr/local/lib/node_modules/wisp/wisp:96:4)
at Module._compile (module.js:449:26)
at Object.exports.run (/usr/local/lib/node_modules/coffee-script/lib/coffee-script/coffee-script.js:68:25)
at compileScript (/usr/local/lib/node_modules/coffee-script/lib/coffee-script/command.js:135:29)
at fs.stat.notSources.(anonymous function) (/usr/local/lib/node_modules/coffee-script/lib/coffee-script/command.js:110:18)
However, I have specified in package.json as a dependancy:
{
"name": "wisp",
"author": "Brendan Scarvell <bscarvell#gmail.com>",
"version": "0.1.0",
"description": "Global nodejs file server",
"dependencies": {
"optimist": "~0.3.4"
},
"repository": "git://github.com/tehlulz/wisp",
"bin": {
"wisp" : "./wisp"
}
}
Does anyone know what to do to get this running? I know its to do with the bin part adding the executable to bin and the node_modules in that directory being empty. No idea how to resolve this.
For anyone else running into this, I had this problem due to my npm installing into a location that's not on my NODE_PATH.
[root#uberneek ~]# which npm
/opt/bin/npm
[root#uberneek ~]# which node
/opt/bin/node
[root#uberneek ~]# echo $NODE_PATH
My NODE_PATH was empty, and running npm install --global --verbose promised-io showed that it was installing into /opt/lib/node_modules/promised-io:
[root#uberneek ~]# npm install --global --verbose promised-io
npm info it worked if it ends with ok
npm verb cli [ '/opt/bin/node',
npm verb cli '/opt/bin/npm',
npm verb cli 'install',
npm verb cli '--global',
npm verb cli '--verbose',
npm verb cli 'promised-io' ]
npm info using npm#1.1.45
npm info using node#v0.8.4
[cut]
npm info build /opt/lib/node_modules/promised-io
npm verb from cache /opt/lib/node_modules/promised-io/package.json
npm verb linkStuff [ true, '/opt/lib/node_modules', true, '/opt/lib/node_modules' ]
[cut]
My script fails on require('promised-io/promise'):
[neek#uberneek project]$ node buildscripts/stringsmerge.js
module.js:340
throw err;
^
Error: Cannot find module 'promised-io/promise'
at Function.Module._resolveFilename (module.js:338:15)
I probably installed node and npm from source using configure --prefix=/opt. I've no idea why this has made them incapable of finding installed modules. The fix for now is to point NODE_PATH at the right directory:
export NODE_PATH=/opt/lib/node_modules
My require('promised-io/promise') now succeeds.
add this to beginning of prog(mac):
module.paths.push('/usr/local/lib/node_modules');
By default node does not look inside the /usr/local/lib/node_module for loading global modules.
Refer the module loading explained in http://nodejs.org/api/modules.html#modules_loading_from_the_global_folders
So either you have to
1)add the /usr/local/lib/node_module to NODE_PATH and export it
or
2)copy the installed node modules to /usr/local/lib/node .
(As explained in the link for loading module node will search in this path and will work)
The following generic fix would for any module. For example with request-promise.
Replace
npm install request-promise --global
With
npm install request-promise --cli
worked (source) and also for globals and inherits
Also, try setting the environment variable
NODE_PATH=%AppData%\npm\node_modules
For some (like me) that nothing else worked, try this:
brew cleanup
brew link node
brew uninstall node
brew install node
Hope it helps someone :)
I got the "optimist" module error and I just did "npm install" to resolve it. went past that error.
https://github.com/mbloch/mapshaper/issues/12
On windows if you just did a clean install and you get this you need blow away your npm cache in \AppData\Roaming
$ vim /etc/profile.d/nodejs.sh
export NODE_PATH=/usr/lib/nodejs:/usr/lib/node_modules:/usr/share/javascript
For Windows, from Nodejs cannot find installed module on Windows? what worked for me is running npm link as in
npm link wisp
I did this in simple way...
Un-Install node from control panel [Windows 7]
Install node again
Install protractor
npm install --global --verbose protractor
Update web driver manager.
works fine for me.
Hope this helps you....
I got this error Error: Cannot find module 'number-is-nan' whereas the module actually exists. It was due to a bad/incomplete Node.js installation.
For Windows , as other answers suggest it, you need a clean Node installation :
Uninstall Node.js
Delete the two folders npm and npm_cache in C:\Users\user\AppData\Roaming
Restart Windows and install Node.js
Run npm initor (npm init --yes for default config)
Set the Windows environment variable for NODE_PATH. This path is where your packages are installed. It's probably something likeNODE_PATH = C:\Users\user\node_modules or C:\Users\user\AppData\Roaming\npm\node_modules
Start a new cmd console and npm should work fine
Note :
Try the last points before reinstalling Node.js, it could save you some time and avoid to re-install all your packages.
For Mac User's It's Best use the manual installation:
To minimize the chance of permissions errors, you can configure npm to
use a different directory. In this example, it will be a hidden
directory on your home folder.
Back-up your computer before you start.
Make a directory for global installations:
mkdir ~/.npm-global
Configure npm to use the new directory path:
npm config set prefix '~/.npm-global'
Open or create a ~/.profile file and add this line:
export PATH=~/.npm-global/bin:$PATH
Back on the command line, update your system variables:
source ~/.profile
Test: Download a package globally without using sudo.
npm install -g jshint
Instead of steps 2-4, you can use the corresponding ENV variable (e.g.
if you don't want to modify ~/.profile):
NPM_CONFIG_PREFIX=~/.npm-global
Reference : https://docs.npmjs.com/getting-started/fixing-npm-permissions
I have just met this problem of the axios module.
Then I tried this: run rm -rf node_modules and yarn.
And it works.
Had the same problem on one of the test servers running Ubuntu under root. Then created a new user using useradd -m myuser and installed everything (nvm, node, packages) as myuser. Now it's working fine.
In my case both node and npm were in same path (/usr/bin). The NODE_PATH was empty, so the npm placed the global modules into /usr/lib/node_modules where require(...) successfully find them.
The only exception was the npm module, which came with the nodejs package. Since I'm using 64 bit system, it was placed into /usr/lib64/node_modules. This is not where require(...) searches in case of empty NODE_PATH and node started from /usr/bin. So I had two options:
link /usr/lib64/node_modules/npm to /usr/lib/node_modules/npm
move modules from /usr/lib/node_modules/* to /usr/lib64/node_modules/ and set NODE_PATH=/usr/lib64/node_modules
Both worked. I'm using OpenSUSE 42.1 and the nodejs package from updates repository. Version is 4.4.5.
I had the same error as the OP, but digging through the logs I could see sh: node: command not found.
It turns out that the /usr/bin/node program (symlink) is no longer installed with apt install nodejs. Once symlinked /usr/bin/node' tonodejs,npm install -g #angular/cli` succeeded.
The proper way to install this on debian is apt install nodejs-legacy.
I had to add C:\Users\{Username}\AppData\Roaming\npm to my env variables and then i could install stuff.
Faced the same issue and got it resolved by adding the below line in my zshrc.
Based on your shell you can try adding in your rc file, for bash and zsh - bashrc/zshrc files present in your home location.
export NODE_PATH="/usr/local/lib/node_modules"
To directly add in zshrc file, run this command
echo 'export NODE_PATH="/usr/local/lib/node_modules"' >> ~/.zshrc
Alpine / Containerization
As mentioned elsewhere, the solution is to bake into your image,
NODE_PATH=/usr/local/lib/node_modules/
I've also opened up an issue upstream with npm apk so this gets set