'Moment' Command not found

#1

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

#2

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

node version node -v
npm version npm -v

#3

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

#4

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?

#5

What’s your operating system?

#6

My operating is Mac OS.

#7

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

#8

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?’

#9

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

exp init newProject
cd newProject
npm install moment --save
#10

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

#11

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
}
}

#12

that is the package.json content

#13

Do you know How to help

#14

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
I downloaded moment but I'm getting a error on my IOS stimulator
#15

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.

#16

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