I'm trying to create an imageboard by building from cloned github repositories. I'm using npm for this, but for reasons I'm not quite sure of, I'm met with errors that I will post below.
I've tried to alleviate this by running: npm cache clean --force, followed by: rm -rf node_modules, and then followed by: rm -rf package-lock.json.
After all of this, I ran npm install && npm run dev once more, and yet still, I was met with the exact same errors.
Initial commands used:
git clone https://gitgud.io/millchan/Millchan.git
npm install && npm run dev
First off, I do: git clone https://gitgud.io/millchan/Millchan.git, and then I do: cd ~/millchan. The "millchan" folder is the one created from cloning the repositories.
Then, afterwards...
After running npm install: https://pastebin.com/kus7p6Cy
(had to post on pastebin because stackoverflow's AI thinks it's spam)
After running npm run dev: https://pastebin.com/KbvggQP2
I am trying to install Yoast.js using Git bash & Github but is stuck. I am installing Yoast.js from its Github repository.
When I open up the example page located in YoastSEO.js\examples\browserified\index.html there is no styling or js included. Just a couple of textareas. My console shows a 404 error with example-browserified.js missing. What am I doing wrong? Below is the step I am running in order to install Yoast.JS:
cd <newsite folder>
git clone https://github.com/Yoast/YoastSEO.js
cd <YoastSEO.js folder>
npm install
npm install -g grunt-cli
grunt build
# Open index.html in the example folder as described above
first configure webpack or laravel mix
then simply run npm install yoastseo --save
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'm trying to setup a MEAN environment. I keep getting this error:
Error: ENOENT, no such file or directory
'/home/user/app1/bower_components/jquery/dist/jquery.min.map'
I've tried on CentOS7 and RHEL6, on CentOS I tried installing nodejs from source and also from epel. On RHEL6 I used this method to setup nodejs:
curl -sL https://rpm.nodesource.com/setup | bash -
yum install -y nodejs
npm install -g mean-cli
mean init app1
cd app1 && node install
grunt
<error>
When I tried bower install I got Failed to execute "git ls-remote --tags --heads git://github.com/angular/bower-angular-mocks.git", exit code of #128 on bower install. To fix this run this command git config --global url."https://".insteadOf git:// I'm not sure if it is persistent.
That fixed the problem on RHEL6 but it didn't fix it on CentOS7. I went back to CentOS7 and tried again and it seems to have worked... I'm just going to move on and not question it for now.
You'll need to run bower install to download those dependencies. You'll have bower.json and maybe package.json (since you are running npm install) in your project root specifying the project dependencies.
I have the following directory structure:
/some_project
source.js
package.json
I would like to install the dependencies for some_project.
I know I could cd into some_project and then run npm install
But I was wondering if it's possible without changing the directory ?
Something like
npm install some_project/package.json
You can use the npm install <folder> variant with the --prefix option. In your scenario the folder and prefix will be the same:
npm --prefix ./some_project install ./some_project
Update: Since the --prefix option exists, I now vote for #coudy's answer to this question. Original answer below:
No, npm will always install in the current directory or, with -g, in the system wide node_modules. You can kind of accomplish this with a subshell though, which won't affect your current directory:
(cd some_project && npm install)
The parentheses makes it run in a subshell.
On windows 10 using powershell the only thing that worked for me without all the problems and edge-cases mentioned in this blog post was this
Start-Process -Wait -FilePath "npm" -ArgumentList "install" -WorkingDirectory $web_dir
Create a package.json in the root directory with the following contents:
{
"dependencies": {
"helloworldprojectname": "file:hello\\world"
}
}
Then call this to install:
npm install --prefix ./hello/world
It installs ./hello/world/node_modules using ./hello/world/package.json.
(Windows 10, Node v10.16.0, npm 7.6.1)
On Windows 10 I couldn't get --prefix to work, so I had to cd and execute it.
cd PATH_TO_FOLDER && npm install