Reputation: 119
In Mac Terminal:
package.json This is most likely not a problem with npm itself.
npm ERR! package.json npm can't find a package.json file in your current directory.
Please include the following file with any support request:
npm ERR! /Users/stickupartist/portfolio/npm-debug.log
stickup-artists-macbook-pro:portfolio stickupartist$ npm init
This utility will walk you through creating a package.json file.
What utility is being referred to?
And next:
Use `npm install <pkg> --save` afterwards to install a package
and
save it as a dependency in the package.json file.
Name: (portfolio)
I type:
npm install <portfolio> --save
And the terminal prints out:
Sorry, name can only contain URL-friendly characters.
What am I doing wrong with my naming? I'm working on my local machine with Meteor, on Mac OS X.
Upvotes: 5
Views: 33091
Reputation: 1
Log out of the session. Then re-login and try npm install -y. This has worked for me.
Upvotes: -2
Reputation: 21
Use: npm init -y
Then install your packages.
That worked for me when I had the same problem.
Upvotes: 2
Reputation: 232
See nem035's answer to create package.json (just npm init
).
For your other problem: in npm install <pkg> --save
refers to the name of a package. You can install the package with its name, without brackets. For example, npm install portfolio --save
Upvotes: 0
Reputation: 35481
To create the package.json
file, you can run npm init (and go through its options) or manually create the file based on these rules.
Here's a simple package.json
file:
{
"name": "my-cool-app",
"version": "1.0.0",
"description": "This is my cool app",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
},
"author": "Me",
"license": "MIT",
"dependencies": {
"jquery": "1.1.1",
}
}
Now, as far as the error:
Sorry, name can only contain URL-friendly characters.
It means that the package name doesn't meet one of the naming rules, mainly:
package name must not contain any non-url-safe characters (since name ends up being part of a URL)
This is most likely happening because you wrapped your package name in <>
.
<>
means it is a placeholder for a value. When actually typing it in, you should overwrite it (and anything it wraps) with some appropriate value, in this case a valid package name.
It is how you would define an npm install
command, not use it:
Definition:
npm install <package_name_goes_here>
Usage
npm install portfolio
Upvotes: 11