Forums

updating node.js and npm

I was following the document but get some error while updating. Hooking up my shell to use nvm source ~/nvm/nvm.sh giving me some error. the errors-

(django2) 15:52 ~ $ cd mysite/
(django2) 15:52 ~/mysite $ git clone https://github.com/creationix/nvm.git
Cloning into 'nvm'...
remote: Enumerating objects: 8355, done.
remote: Counting objects: 100% (101/101), done.
remote: Compressing objects: 100% (61/61), done.
remote: Total 8355 (delta 48), reused 82 (delta 40), pack-reused 8254
Receiving objects: 100% (8355/8355), 3.02 MiB | 29.48 MiB/s, done.
Resolving deltas: 100% (5271/5271), done.
Updating files: 100% (318/318), done.
(django2) 16:08 ~/mysite $ source ~/nvm/nvm.sh
bash: /home/webclip/nvm/nvm.sh: No such file or directory

The last line giving me a headache.

You were in ~/mysite when you cloned the repo, so nvm is not in ~/nvm, it's in ~/mysite/nvm

Ok

node.js is working now but giving a npm error

(django2) 15:00 ~/mysite $ npm install --global
npm ERR! code ENOLOCAL
npm ERR! Could not install from "" as it does not contain a package.json file.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/webclip/.npm/_logs/2021-08-18T15_00_22_499Z-debug.log
(django2) 15:00 ~/mysite $

You need to provide an argument which would point to a node package (look at the error message that you copied), in other words -- you need to tell npm what you want to be installed.

so if i want to install react what command should i use now?

As @pafk said, you need to specify what you want to install. So if you want to install an npm package called react, you would use:

npm install react --global

ok

again same problem-

(django2) 15:32 ~/mysite $ source ~mysite/nvm/nvm.sh
bash: ~mysite/nvm/nvm.sh: No such file or directory
(django2) 15:32 ~/mysite $

You're missing a slash between the ~ and mysite.

Permission denied

(django2) 15:50 ~/mysite $ ~/mysite/nvm/nvm.sh
bash: /home/webclip/mysite/nvm/nvm.sh: Permission denied
(django2) 15:51 ~/mysite $

The story is, I update the node.js before, that time nvm commands was working but after one day when i try to install react with npm install react --global ,it says npm: command not found . So , I try to hook up the nvm with bash and the above problem occured.

Is nvm.sh executable?

What is the result of ls -l /home/webclip/mysite/nvm/nvm.sh

this is the result of ls -l /home/webclip/mysite/nvm/nvm.sh

(django2) 13:49 ~/mysite $ ls -l /home/webclip/mysite/nvm/nvm.sh
-rw-rw-r-- 1 webclip registered_users 136390 Aug 17 16:08 /home/webclip/mysite/nvm/nvm.sh
(django2) 13:50 ~/mysite $

It's not an executable -- if you consider it safe to be executed, run chmod +x <filename> which will make the file executable.

which file? nvm.sh ?

Yes, the one you're trying to run.

did with nvm.sh filenname

(django2) 13:50 ~/mysite $ chmod +x <nvm.sh>                                                                                              
bash: syntax error near unexpected token `newline'

this the error

Sorry, "<filename>" was a placeholder -- use file path without brackets ("<", ">").

didn't get it correctly

(django2) 14:54 ~/mysite $ chmod +x --mysite/nvm/nvm.sh
chmod: unrecognized option '--mysite/nvm/nvm.sh'
Try 'chmod --help' for more information.

what i'm missing?

Btw i'm using this account(webclip).

chmod +x nvm.sh is not working

You need to use the filename of the file that you're trying to chmod. From earlier messages, it looks like you have nvm.sh here /home/webclip/mysite/nvm/nvm.sh. So you want:

chmod +x /home/webclip/mysite/nvm/nvm.sh

npm error when trying to create a react app

(django2) 14:03 ~/mysite $ npm install react --global
+ react@17.0.2
added 4 packages from 3 contributors in 1.56s
(django2) 14:04 ~/mysite $ npx create-react-app frontend
npx: installed 67 in 11.944s
Creating a new React app in /home/webclip/mysite/frontend.
Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts with cra-template...
npm ERR! code Unknown system error -122
npm ERR! syscall mkdir
npm ERR! path /home/webclip/mysite/frontend/node_modules/.staging/parse-json-904f65b0
npm ERR! errno -122
npm ERR! Unknown system error -122: Unknown system error -122, mkdir 
'/home/webclip/mysite/frontend/node_modules/.staging/parse-json-904f6
5b0'
npm ERR! A complete log of this run can be found in:
npm ERR!     /home/webclip/.npm/_logs/2021-08-25T14_09_02_386Z-debug.log
Aborting installation.
  npm install --save --save-exact --loglevel error react react-dom react-scripts cra-template has failed.
Deleting generated file... node_modules
Deleting generated file... package.json
Deleting frontend/ from /home/webclip/mysite
Done.
(django2) 14:09 ~/mysite $

Is it because of storage(currently 76% full)?

Yes, unfortunately. I just did some experimenting and it appears that React has grown bigger and the installation requires more than 500M available on a free account. It appears that you need at least a Hacker account to use React nowadays...

ok thanks. what If i use of react cdn or angular or vue.js? which will be suitable in the diskspace of free account?

You need to experiment -- the JavaScript environment is rapidly changing (for example free account's disk space used to be enough for React).

I just update nvm and node.js and installed restframework, corsheaders thats all... it takes 75%. Why so much space? What if we use react older version?

React uses a lot of javascript modules and probably also has multiple copies of the same modules. It may be smaller if you use an older version. However, it may be better if you did our javascript development locally and then just uploaded the compiled javascript, which would be significantly smaller.

Ok