'Moment' Command not found

I typed ‘npm install moment --save’ into terminal and it said command not found. Can someone please help me to resolve this issue.

Hi there, can you provide a few more details about your environment?

node version node -v
npm version npm -v

Hi, davepack thank you for response. I tried ‘upgrade brew node’ and my issue was resolved.

Nevermind, I thought I fixed it.
my node version: v8.5.0.
my npm version npm -v: 5.4.2

Do you know how to help me?

What’s your operating system?

My operating is Mac OS.

To clarify, running npm install moment --save returned bash: npm: command not found?

I’m trying to run the moment command. The command I used was 'npm install moment --save. Previously I was getting ‘command not found.’ Now I am getting this message ‘Refusing to install package with name “moment” under a package
npm ERR! also called “moment”. Did you name your project the same
npm ERR! as the dependency you’re installing?’

Can you reproduce this error by creating a new project and installing moment?

exp init newProject
cd newProject
npm install moment --save

Also, can you paste the contents of the package.json file in the directory where you’re trying to install moment?

Started a new project got the same message.

“name”: “jjapp”,
“version”: “0.0.0”,
“description”: “Hello Expo!”,
“author”: null,
“private”: true,
“main”: “node_modules/expo/AppEntry.js”,
“dependencies”: {
“expo”: “^21.0.0”,
“react”: “16.0.0-alpha.12”,
“react-native”: “https://github.com/expo/react-native/archive/sdk-21.0.2.tar.gz

that is the package.json content

Do you know How to help

Perhaps you had named your project ‘moment’ at some point in time? How about resetting your npm install directory and trying again?

In your project directory:
rm -rf node_modules
npm install moment --save

If something else is still failing, can you post a screenshot of your terminal here?

1 Like

thanks for your help. I figured it out. I had to create a modules folder and save moment.js in it. Then I had to import moment from ‘./modules/moment.js’ into one of my files.

can you explain how you figured it out? in details. Perhaps step by step