Glitch command line

So I’m trying to follow these instructions to get es6 functions working on glitch, and this is my first time hearing about the console on glitch, so I ran the first command in the article npm i -g express-generator and I got the error

checkPermissions Missing write access to /opt/nvm/versions/node/v10.15.3/lib/node_modules
npm ERR! code EACCES
npm ERR! syscall access
npm ERR! path /opt/nvm/versions/node/v10.15.3/lib/node_modules
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, access '/opt/nvm/versions/node/v10.15.3/lib/node_modules'

I tried googling the error and came across this suggestion: sudo chown -R $USER [pathname]

apparently sudo isn’t a recognized command in the glitch envrionment. Does anyone know how I can use npm to get the package installed?

I do have "npm": "^6.12.1" in my dependencies and here is a link to my project

Hey @TaraBryn,

Glitch console does not permit the adding of npm packages through the Glitch Console. To add packages to your project, click the Add Package button at the top of your package.json and type in the name of the package you want to add. In this case, it is express-generator. Click on the first result that you see. It should look like this:

1 Like

@khalby786 thank you! Could you please tell me why I have one project where I remixed sample code to get the null propagation operator to work, and it seems to be successful on the remixed project, but when I add the relevant .eslintrc.json file to my working project, I’m still getting errors with the ?. notation

one way to fix this is to run

npm i express-generator

instead of

npm i -g express-generator

as glitch does not allow the installation of global (-g) packages, only local

it is also suggested that you use the built in package finder like in post 2 or PNPM as shown below

pnpm add <PACKAGE-NAME>; refresh; echo 'done'

and as usual, i have packages in the works for these issues

2 Likes

As @J-Tech-Foundation, you cannot install packages globally on glitch, and to add to that, you must use pnpm instead of npm

1 Like

@J-Tech-Foundation thanks, that worked (or at least it didn’t give any errors) @Callum-OKane I was able to use just npm i express-generator without pnpm (not even sure what that is). After @khalby786’s explanation, I thought that using the command would just add it as a dependency in package.json but it didn’t, so 'm assuming it installed it in the background? the message said it created a package-lock .json file, which I don’t even see in the file tree anyway, but it does show up when I run a dir command. I’m guessing that the i param in the npm command stands for install and to remove it, I would use npm r express-generator? Would simply deleting the package-lock.json file also accomplish the same thing?

pnpm is the cloud version of npm, it just works faster, and takes up less space.

why package-lock.json does not show up is because it is listed in the global glitch gitignore file (gggf)

for uninstall, deleting package-lock.json could completely crash the entirety of the node client of your project, yes it is a work around, but it deletes and re install all dependencies, causing a lengthy install, and then an all out crash of node after a while because of process stress.

and,

npm r express-generator

does work, but

pnpm remove express-generator

is recommended, especially if you used the built in package browser of pnpm altogether

sorry callum, but glitch does not specify wether they require all users to use pnpm over npm and vice versa.

so, yes, pnpm is recommended, but npm is still up there tied,

and i explained explicity that glitch does not allow the installation of global packages, plus the fact that any global package could effect other projects within the host where the project with global packages resides.

and