not able to install npm without sudo - node.js

I've installed node into a custom directory in my home folder called local per these instructions : https://gist.github.com/isaacs/579814
I've added the location to my PATH and it seems to work fine. I cannot however seem to get npm to install without sudo. From what I can tell it is trying to execute a command in /bin folder.
The command I am running from ~/local/npm is make install and I got the latest versions of both node and npm from github.
Can anyone assist here?
user#localhost [~/local/npm]# make install
rm -rf \
.building_ronn \
html/doc \
html/api \
man
scripts/doc-build.sh doc/api/npm-view.md man/man3/npm-view.3
make[1]: Entering directory `/home1/extrabol/local/npm'
node cli.js install ronn --no-global
npm ERR! Error: EROFS, mkdir '/bin/node'
npm ERR! at Error (native)
npm ERR! If you need help, you may report this *entire* log,
npm ERR! including the npm and node versions, at:
npm ERR! <http://github.com/npm/npm/issues>
npm ERR! System Linux 3.4.87-20140414.1.bh6.x86_64
npm ERR! command "node" "/home1/extrabol/local/npm/cli.js" "install" "ronn" "--no-global"
npm ERR! cwd /home1/extrabol/local/npm
npm ERR! node -v v0.11.14-pre
npm ERR! npm -v 1.4.10
npm ERR! path /bin/node
npm ERR! code EROFS
npm ERR! errno -30
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /home1/extrabol/local/npm/npm-debug.log
npm ERR! not ok code 0
The Debug Log reports this
0 info it worked if it ends with ok
1 verbose cli [ 'node',
1 verbose cli '/home1/extrabol/local/npm/cli.js',
1 verbose cli 'install',
1 verbose cli 'ronn',
1 verbose cli '--no-global' ]
2 info using npm#1.4.10
3 info using node#v0.11.14-pre
4 verbose node symlink /home1/extrabol/local/node/node
5 error Error: EROFS, mkdir '/bin/node'
5 error at Error (native)
6 error If you need help, you may report this *entire* log,
6 error including the npm and node versions, at:
6 error <http://github.com/npm/npm/issues>
7 error System Linux 3.4.87-20140414.1.bh6.x86_64
8 error command "node" "/home1/extrabol/local/npm/cli.js" "install" "ronn" "--no-global"
9 error cwd /home1/extrabol/local/npm
10 error node -v v0.11.14-pre
11 error npm -v 1.4.10
12 error path /bin/node
13 error code EROFS
14 error errno -30

Figured it out. Looks like when I git cloned the npm files somehow I didn't have ownership over all of the files. a quick chown -R on the npm folder fixed the issue.

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

npm building issues for SyntaxHighlighter

I'm a beginner with npm and is trying to build SyntaxHighlighter version 4 by cloning it using git first, but failed. Here are the errors I got:
1 error generated.
make: *** [Release/obj.target/binding/src/create_string.o] Error 1
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/Users/name/syntaxhighlighter/node_modules/node-gyp/lib/build.js:262:23)
gyp ERR! stack at ChildProcess.emit (events.js:311:20)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:275:12)
gyp ERR! System Darwin 19.3.0
gyp ERR! command "/usr/local/bin/node" "/Users/name/syntaxhighlighter/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd /Users/name/syntaxhighlighter/node_modules/node-sass
gyp ERR! node -v v12.16.1
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
Build failed with error code: 1
npm WARN notsup Unsupported engine for karma#0.13.22: wanted: {"node":"0.10 || 0.12 || 4 || 5"} (current: {"node":"12.16.1","npm":"6.13.4"})
npm WARN notsup Not compatible with your version of node/npm: karma#0.13.22
npm WARN syntaxhighlighter#4.0.1 No description
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! node-sass#3.13.1 postinstall: `node scripts/build.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the node-sass#3.13.1 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! /Users/name/.npm/_logs/2020-04-05T02_52_17_048Z-debug.log
The problem you are running into is that SyntaxHighlighter version 4 is too old and its dependencies are not supported by the version of Node you are running.
The package that the error is coming from is Karma. The version of Karma that is trying to install is v0.13.22. That version of Karma only supported a maximum Node version of 5, and you appear to be running version 12.
You could potentially solve this issue by downgrading your Node version, or using a tool like Node Version Manager (NVM) to temporarily downgrade your Node version.
NVM
Try to install node_modules only.
cd /syntaxhighlighter/node_modules$ and then try installing using npm install.
There are some errors in gulp.js file that are causing problems in the installation process. I have tried older versions but none of them is available. Hope this will work out.
robdonn's NVM solution works, however, I had a very unusual instance when running multiple versions of Node, managed through NVM, was breaking my ApiConnect/Loopback client (only on a Mac). I never figured out why but realize that running a single version of Node fixed the problem.
Also wanting to use syntaxhighlighter, I did manage to generate the syntaxhighlighter.js file using a Docker container. In the cloned directory I added the Dockerfile.
FROM node:5
# Create app directory
WORKDIR /usr/src/app
# Install app dependencies
# A wildcard is used to ensure both package.json AND package-lock.json are copied
# where available (npm#5+)
COPY package*.json ./
RUN npm install
# Bundle app source
COPY . .
Thereafter I was able to:
Build a local docker container
docker build -t syntaxhighlighter .
Run the container mapping my local dist directory to the container's dist directory
docker run -i --volume ~/github/syntaxhighlighter/dist:/usr/src/app/dist syntaxhighlighter
Got the container id for the local running container
docker ps
Used the container id to go into the container (could have also just put CMD ['/bin/sh'] in my Dockerfile)
docker exec -it <the-container-id> /bin/sh
Ran the gulp build from the Node v5 container. Since I am mapping my local dist directory to the container's dist directory, I get the output locally.
./node_modules/gulp/bin/gulp.js build --brushes=all --compat

NPM run dev command always fails at "grunt develop:quick" script

Using a cloned repository, I am trying to run npm run dev in order to develop locally. I have installed the grunt commands globally and my npm is recently updated. A possible problem I can see is that my node.js is at 5.10. However, if possible, I'd like to keep it there due to other team members having history with the repository not working on updated versions of node.js. The root of my repository is saved in the web folder and this is through Windows PowerShell(Admin).
PS C:\Users\<User>\Documents\GitHub\web> npm run dev
> web#12.5.6 dev C:\Users\<User>\Documents\GitHub\web
> grunt develop:quick
Running "develop:quick" (develop) task
Running "clean:server" (clean) task
>> 0 paths cleaned.
Running "copy:modules" (copy) task
Copied 24 files
Running "base-sass-config" task
Interim sass config file [client\styles\core\__config.scss] created.
Running "glob-sass-components" task
Traversing:
C:\Users\oalyousf\Documents\GitHub\web\client\src\components\pages
Traversing:
C:\Users\oalyousf\Documents\GitHub\web\client\src\components\building-blocks
Interim components glob file [client\styles\core\__components.scss] created.
Running "sass:static" (sass) task
>> File to import not found or unreadable: ....srcomponentspages­min-
consolestyles­min-console.scss
>> Parent style sheet:
C:/Users/<User>/Documents/GitHub/web/client/styles/core/__components.scss
>> Line 4 Column 1 client\styles\core\__components.scss
Warning: Use --force to continue.
Aborted due to warnings.
npm ERR! Windows_NT 10.0.16299
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program
Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "dev"
npm ERR! node v5.10.1
npm ERR! npm v3.8.3
npm ERR! code ELIFECYCLE
npm ERR! web#12.5.6 dev: `grunt develop:quick`
npm ERR! Exit status 6
npm ERR!
npm ERR! Failed at the web#12.5.6 dev script 'grunt develop:quick'.
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 web package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! grunt develop:quick
npm ERR! You can get information on how to open an issue for this project
with:
npm ERR! npm bugs web
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls web
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! C:\Users\<User>\Documents\GitHub\web\npm-debug.log
PS C:\Users\<User>\Documents\GitHub\web>

npm run npm bin from within the same package

I'm working on extending open source raml2html library, which consumes raml contract to generate html docs. Key facts:
the library has a binary placed in bin/raml2html file; th ebinary is stated in package.json as follows:
"bin": {
"raml2html": "./bin/raml2html"
}
when npm install'ed by the users, the program is executed
I use the binary to update examples: both source .raml files and output .html files are kept in the repo. I'm using the binary with ./bin/raml2html examples/example.raml -o examples/example.html with git bash under windows and it works fine.
however, I want to wrap this commands as npm run script, so I define:
"scripts": {
...
"examples:example": "./bin/raml2html examples/example.raml -o examples/example.html",
"examples:github": "./bin/raml2html examples/github.raml -o examples/github.html",
"examples": "npm run examples:example && examples:github"
},
and when I call either npm run examples or npm run examples:example, both fail the same way:
`
$ npm run examples:example
> raml2html#2.4.0 examples:example C:\Users\tomasz.ducin\Development\GitHub\raml2html
> ./bin/raml2html examples/example.raml -o examples/example.html
'.' is not recognized as an internal or external command,
operable program or batch file.
npm ERR! Windows_NT 6.1.7601
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "examples:example"
npm ERR! node v4.4.3
npm ERR! npm v2.15.1
npm ERR! code ELIFECYCLE
npm ERR! raml2html#2.4.0 examples:example: `./bin/raml2html examples/example.raml -o examples/example.html`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the raml2html#2.4.0 examples:example script './bin/raml2html examples/example.raml -o examples/example.html'.
npm ERR! This is most likely a problem with the raml2html package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! ./bin/raml2html examples/example.raml -o examples/example.html
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs raml2html
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!
npm ERR! npm owner ls raml2html
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! C:\Users\tomasz.ducin\Development\GitHub\raml2html\npm-debug.log
It says that '.' is not recognized as an internal or external command - well, that's true, ./bin/raml2html is not how I should do that on windows. But it's being ran under node.js/npm layer and package.json:bin can understand this syntax. I get confused with that.
The question is: how can I set up npm run scrpt to use the binary inside the same package?

npm start gives the error that server.js is not a valid win32 application

I'm trying to start the application server for a group project I'm doing. I posted my error below and I'll copy the npm-debug.log contents below.
This works perfectly fine my teammates mac laptop. I'm trying to run this on a Windows 8 64 bit machine. I tried with both the 32 bit and 64 bit binaries of node and it gives the same output.
output from npm start
Windows PowerShell Copyright (C) 2013 Microsoft Corporation. All
rights reserved.
C:\Users\damien\Documents\GitHub\lend [development]> npm start
lending-app#0.0.1 start C:\Users\damien\Documents\GitHub\lend
brunch watch --server
05 Apr 22:01:49 - error: couldn't load server lend.js: Error: %1 is
not a valid Win32 application.
C:\Users\damien\Documents\GitHub\lend\node_modules\client-sessions\node_modules\node-proxy\build\Release\nodeproxy.node
C:\Users\damien\AppData\Roaming\npm\node_modules\brunch\lib\watch.js:105
if (server.startServer == null) {
^ TypeError: Cannot read property 'startServer' of undefined
at startServer (C:\Users\damien\AppData\Roaming\npm\node_modules\brunch\lib\watch.js:105:17)
at C:\Users\damien\AppData\Roaming\npm\node_modules\brunch\lib\watch.js:418:18
at C:\Users\damien\AppData\Roaming\npm\node_modules\brunch\lib\helpers.js:475:14
at C:\Users\damien\AppData\Roaming\npm\node_modules\brunch\node_modules\read-components\index.js:207:16
at C:\Users\damien\AppData\Roaming\npm\node_modules\brunch\node_modules\read-components\index.js:34:14
at Object.cb [as oncomplete] (fs.js:168:19)
npm ERR! lending-app#0.0.1 start: brunch watch --server npm ERR!
Exit status 8 npm ERR! npm ERR! Failed at the lending-app#0.0.1 start
script. npm ERR! This is most likely a problem with the lending-app
package, npm ERR! not with npm itself. npm ERR! Tell the author that
this fails on your system: npm ERR! brunch watch --server npm ERR!
You can get their info via: npm ERR! npm owner ls lending-app npm
ERR! There is likely additional logging output above. npm ERR! System
Windows_NT 6.2.9200 npm ERR! command "C:\Program
Files\nodejs\\node.exe" "C:\Program
Files\nodejs\node_modules\npm\bin\npm-cli.js" "start" npm ERR!
cwd C:\Users\damien\Documents\GitHub\lend npm ERR! node -v v0.10.26
npm ERR! npm -v 1.4.3 npm ERR! code ELIFECYCLE npm ERR! npm ERR!
Additional logging details can be found in: npm ERR!
C:\Users\damien\Documents\GitHub\lend\npm-debug.log npm ERR! not ok
code 0 C:\Users\damien\Documents\GitHub\lend [development]>
npm-debug.log
0 info it worked if it ends with ok
1 verbose cli [ 'C:\Program Files\nodejs\\node.exe',
1 verbose cli 'C:\Program
Files\nodejs\node_modules\npm\bin\npm-cli.js',
1 verbose cli 'start' ]
2 info using npm#1.4.3
3 info using node#v0.10.26
4 verbose node symlink C:\Program Files\nodejs\node.exe
5 verbose run-script [ 'prestart', 'start', 'poststart' ]
6 info prestart lending-app#0.0.1
7 info start lending-app#0.0.1
8 verbose unsafe-perm in lifecycle true
9 info lending-app#0.0.1 Failed to exec start script
10 error lending-app#0.0.1 start: brunch watch --server
10 error Exit status 8
11 error Failed at the lending-app#0.0.1 start script.
11 error This is most likely a problem with the lending-app package,
11 error not with npm itself.
11 error Tell the author that this fails on your system:
11 error brunch watch --server
11 error You can get their info via:
11 error npm owner ls lending-app
11 error There is likely additional logging output above.
12 error System Windows_NT 6.2.9200
13 error command "C:\Program Files\nodejs\\node.exe" "C:\Program
Files\nodejs\node_modules\npm\bin\npm-cli.js" "start"
14 error cwd C:\Users\damien\Documents\GitHub\lend
15 error node -v v0.10.26
16 error npm -v 1.4.3
17 error code ELIFECYCLE
18 verbose exit [ 1, true ]
npm start calls the scripts.start entry in your package.json file. In this case it looks like the command is brunch watch --server. Chances are you are missing the brunch binary which is causing npm to spit out the error.

Resources