npm init not creating package.json on my mac - json

When I try to create a package.json file using npm init I keep getting the following:
npm http GET https://registry.npmjs.org/init
npm http 304 https://registry.npmjs.org/init
npm http GET https://registry.npmjs.org/daemon
npm http 304 https://registry.npmjs.org/daemon
init#0.1.2 node_modules/init
└── daemon#1.1.0
What is wrong? I have looked everywhere and I cannot find an answer.
Here is what I get when I run the following command:
Amens-Mac-mini:~ amenmojara$ npm init =ddd
npm http GET https://registry.npmjs.org/%3Dddd
npm http GET https://registry.npmjs.org/init
npm http 304 https://registry.npmjs.org/init
npm http 404 https://registry.npmjs.org/%3Dddd
npm ERR! 404 '%3Dddd' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it
npm ERR! 404
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, or http url, or git url.
npm ERR! System Darwin 13.0.0
npm ERR! command "/usr/local/Cellar/node/0.10.26/bin/node" "/usr/local/bin/npm" "install" "init" "=ddd"
npm ERR! cwd /Users/amenmojara
npm ERR! node -v v0.10.26
npm ERR! npm -v 1.4.3
npm ERR! code E404
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /Users/amenmojara/npm-debug.log
npm ERR! not ok code 0

Try this.
Go to terminal.
Change directory location where you want to create a file.
cd your_destination_folder
Type npm init and press enter.
It ask for name, version, description, entry point, test command, git repository, keywords, author, license. Pass those values.
Then it prompt, Is this ok? (yes). Enter yes.
Hurray, your package.json file is created.

You are doing npm install init instead of npm init. Just check if your npm <something> is not aliased to npm install <something>

Related

npm errors when I try to deploy website to github

getting errors in the terminal when trying to use npm to deploy a website on github
I have no idea what to try
PS C:\Users\user\modern_portfolio> npm run deploy
> modern_portfolio#1.0.0 deploy C:\Users\user\modern_portfolio
> gh-pages -d dist
The "file" argument must be of type string. Received type undefined
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! modern_portfolio#1.0.0 deploy: `gh-pages -d dist`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the modern_portfolio#1.0.0 deploy script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\user\AppData\Roaming\npm-cache\_logs\2019-08-04T04_12_42_515Z-debug.log
Newer version 2.1 has some issue. They are probably working on it. Revert back to 2.0.1.
Reinstall Github pages with a specific version:
npm uninstall gh-pages
npm i gh-pages#2.0.1
npm run deploy // as usual

Artifactory npm publish failed PUT 404

I am trying to publish scoped npm packages to artifactory and I get the following error:
npm ERR! registry error parsing json
npm ERR! publish Failed PUT 404
npm ERR! Darwin 15.4.0
npm ERR! argv "/usr/local/Cellar/node4-lts/4.6.2/bin/node" "/usr/local/bin/npm" "publish"
npm ERR! node v4.6.2
npm ERR! npm v2.15.9
npm ERR! Unexpected token <
npm ERR! <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
npm ERR! <html><head>
npm ERR! <title>404 Not Found</title>
npm ERR! </head><body>
npm ERR! <h1>Not Found</h1>
npm ERR! <p>The requested URL /artifactory/api/npm/npm-local/#acres/acresmetajs was not found on this server.</p>
npm ERR! <hr>
npm ERR! <address>Apache/2.2.31 (Amazon) Server at artifacts.company.com Port 80</address>
npm ERR! </body></html>
I have set up my .npmrc file the following way:
registry=http://artifacts.company.com/artifactory/api/npm/npm-local/
_auth="mypassword"
always-auth=true
email=d.griner#company.com
#acres:registry=http://artifacts.company.com/artifactory/api/npm/npm-local/
//artifacts.company.com/artifactory/api/npm/npm-local/:_password=mypassword
//artifacts.company.com/artifactory/api/npm/npm-local/:username=myusername
//artifacts.company.com/artifactory/api/npm/npm-local/:email=d.griner#company.com
//artifacts.company.com/artifactory/api/npm/npm-local/:always-auth=true
I run npm publish and npm publish --registry http://artifacts.company.com/artifactory/api/npm/npm-local/ and get this same error. What am I missing?
I've found there are a couple more steps for getting scoped packages to work with artifactory if it's behind maven. https://techblog.dorogin.com/setting-up-artifactory-as-npm-repository-behind-apache-7541d5140492#.z0q412z5j
Essentially:
AllowEncodedSlashed set to NoDecode (by default it’s Off)
Added keyword nocanon for ProxyPass, it tells mod_proxy module not to canonicalize URLs
I got this on version 6.5.0. And the solution was remove "engines" group from in package.json.
npm ERR! publish Failed PUT 404
npm ERR! code E404
npm ERR! 404 NotFound The package 'xxxxxxxx' was not found in feed 'npmjs': xxxxxxxx
npm ERR! 404
npm ERR! 404 'xxxxxxxx' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
npm ERR! 404
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.

Unable to install local modules in package.json dependency list. Defined by file path

I have the following package.json at the root of my app.
....
"dependencies": {
"LessonApi": "file:apis/lesson",
"SearchAPI": "file:apis/search",
"SlotApi": "file:apis/slots",
"UserAPI": "file:apis/user",
"bcrypt": "^0.8.3",
"co": "^4.5.4",
"co-mysql": "^1.0.0",
"koa": "^0.20.0",
"koa-basic-auth": "^1.1.2",
"koa-bodyparser": "^2.0.0",
"koa-cors": "0.0.16",
"koa-generic-session": "^1.9.0",
"koa-mount": "^1.3.0",
"koa-passport": "^1.1.6",
"koa-router": "^5.1.2",
"koa-session": "^3.3.0",
"mysql": "^2.7.0",
"passport-facebook": "^2.0.0",
"sql-fixtures": "^0.11.0"
},
.....
I have a custom module at /apis/lesson. But as soon as I do npm install at the root of the app it fails and gives me this error.
git clone git#github.com:file:apis/slots Cloning into bare repository '/root/.npm/_git-remotes/git-github-com-file-apis-slots-6576eaee'...
npm ERR! git clone git#github.com:file:apis/slots fatal: remote error:
npm ERR! git clone git#github.com:file:apis/slots is not a valid repository name
npm ERR! git clone git#github.com:file:apis/slots Email support#github.com for help
npm ERR! git clone git#github.com:file:apis/lesson Cloning into bare repository '/root/.npm/_git-remotes/git-github-com-file-apis-lesson-7b1b575f'...
npm ERR! git clone git#github.com:file:apis/lesson fatal: remote error:
npm ERR! git clone git#github.com:file:apis/lesson is not a valid repository name
npm ERR! git clone git#github.com:file:apis/lesson Email support#github.com for help
npm ERR! 404 404 Not Found: SlotApi
npm ERR! 404
npm ERR! 404 'SlotApi' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it
npm ERR! 404 It was specified as a dependency of 'GetGoAPI'
npm ERR! 404
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, or http url, or git url.
npm ERR! System Linux 3.13.0-52-generic
npm ERR! command "/usr/bin/node" "/usr/bin/npm" "install"
....
Please explain why this would not work since logically I feel as though I should be able to have local dependency.
For anyone else that might stumble upon this, #Tom Robinson's comment answered the question correctly. I just needed to update to npm v 2.0.0.
Which can be done by:
sudo npm install npm -g
file: was added as part of version 2.0.0 so npm will need to be upgraded.

Package.json - not able to install the modules

I have a empty folder, In which I created a package.json file, which contains this:
{
"name":"sample project",
"version":"0.0.1",
"title":"My grunt App",
"homepage":"http://gruntjs.com"
}
later on in the same folder, I am trying to run this command:
npm install grunt --save-dev
But I am getting error like this: not able to install the grunt at all
D:\grunt2>npm install grunt --save-dev
npm ERR! Error: Invalid name: "sample project"
npm ERR! at ensureValidName (C:\Program Files (x86)\nodejs\node_modules\npm\
node_modules\read-package-json\node_modules\normalize-package-data\lib\fixer.js:
300:15)
npm ERR! at Object.module.exports.fixNameField (C:\Program Files (x86)\nodej
s\node_modules\npm\node_modules\read-package-json\node_modules\normalize-package
-data\lib\fixer.js:204:5)
npm ERR! at C:\Program Files (x86)\nodejs\node_modules\npm\node_modules\read
-package-json\node_modules\normalize-package-data\lib\normalize.js:30:38
npm ERR! at Array.forEach (native)
npm ERR! at normalize (C:\Program Files (x86)\nodejs\node_modules\npm\node_m
odules\read-package-json\node_modules\normalize-package-data\lib\normalize.js:29
:15)
npm ERR! at final (C:\Program Files (x86)\nodejs\node_modules\npm\node_modul
es\read-package-json\read-json.js:342:33)
npm ERR! at then (C:\Program Files (x86)\nodejs\node_modules\npm\node_module
s\read-package-json\read-json.js:126:33)
npm ERR! at C:\Program Files (x86)\nodejs\node_modules\npm\node_modules\read
-package-json\read-json.js:316:48
npm ERR! at fs.js:207:20
npm ERR! at OpenReq.Req.done (C:\Program Files (x86)\nodejs\node_modules\npm
\node_modules\graceful-fs\graceful-fs.js:144:5)
npm ERR! If you need help, you may report this *entire* log,
npm ERR! including the npm and node versions, at:
npm ERR! <http://github.com/npm/npm/issues>
npm ERR! System Windows_NT 6.1.7601
npm ERR! command "C:\\Program Files (x86)\\nodejs\\\\node.exe" "C:\\Program File
s (x86)\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "grunt" "--save-d
ev"
npm ERR! cwd D:\grunt2
npm ERR! node -v v0.10.28
npm ERR! npm -v 1.4.9
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! D:\grunt2\npm-debug.log
npm ERR! not ok code 0
Not able to understand the issue. any one help me please?
Actually i am trying to reproduce this tutorial: http://www.anujgakhar.com/2013/02/28/writing-a-simple-grunt-task-using-gruntjs/
Don't use a space in the project name. Change, eg, to sample-project.
(That's the very first error line, btw: Error: Invalid name: "sample project")
The name-field in package.json is invalid, precisely as the error says. Remove the space (use a dot or a dash instead) and it should be fine. According to the developers this is by design since the name will be used in urls, folders etc.

npm package build failing, how best to debug?

I'm trying to install a mysql node package on Mac OS X. I'm trying to run a client project locally.
I have node and npm installed already and they work fine, other packages have installed fine. I've also compiled/installed the full LAMP stack.
When the build below fails, I'm not seeing any error messages that are helpful - just information about a library not being found. Without knowing what it can't find, I can't fix it.
Any advice? MySQL has been installed the standard way - downloaded packages, ./configure'd, make/install.
$ npm install mysql-libmysqlclient
npm http GET https://registry.npmjs.org/mysql-libmysqlclient
npm http 304 https://registry.npmjs.org/mysql-libmysqlclient
> mysql-libmysqlclient#1.3.3 install /Users/botskonet/node_modules/mysql-libmysqlclient
> node-gyp rebuild
info it worked if it ends with ok
spawn python [ '/Users/botskonet/.node-gyp/0.6.12/tools/gyp_addon',
'binding.gyp',
'-I/Users/botskonet/node_modules/mysql-libmysqlclient/build/config.gypi',
'-f',
'make' ]
spawn make [ 'BUILDTYPE=Release', '-C', 'build' ]
CXX(target) Release/obj.target/mysql_bindings/src/mysql_bindings.o
CXX(target) Release/obj.target/mysql_bindings/src/mysql_bindings_connection.o
CXX(target) Release/obj.target/mysql_bindings/src/mysql_bindings_result.o
CXX(target) Release/obj.target/mysql_bindings/src/mysql_bindings_statement.o
SOLINK_MODULE(target) Release/mysql_bindings.node
ld: library not found for -lmysqlclient_r
collect2: ld returned 1 exit status
make: *** [Release/mysql_bindings.node] Error 1
ERR! Error: `make` failed with exit code: 2
at Array.0 (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:176:25)
at EventEmitter._tickCallback (node.js:192:40)
ERR! not ok
npm ERR! mysql-libmysqlclient#1.3.3 install: `node-gyp rebuild`
npm ERR! `sh "-c" "node-gyp rebuild"` failed with 1
npm ERR!
npm ERR! Failed at the mysql-libmysqlclient#1.3.3 install script.
npm ERR! This is most likely a problem with the mysql-libmysqlclient package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-gyp rebuild
npm ERR! You can get their info via:
npm ERR! npm owner ls mysql-libmysqlclient
npm ERR! There is likely additional logging output above.
npm ERR!
npm ERR! System Darwin 11.3.0
npm ERR! command "node" "/usr/local/bin/npm" "install" "mysql-libmysqlclient"
npm ERR! cwd /Users/botskonet/Sites/SportsBuddies
npm ERR! node -v v0.6.12
npm ERR! npm -v 1.1.15
npm ERR! code ELIFECYCLE
npm ERR! message mysql-libmysqlclient#1.3.3 install: `node-gyp rebuild`
npm ERR! message `sh "-c" "node-gyp rebuild"` failed with 1
npm ERR! errno {}
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /Users/botskonet/Sites/SportsBuddies/npm-debug.log
npm not ok
Look at the dependencies section in README and issues #107. To build mysql-libmysqlclient you should install both libmysqlclient and development headers for it, add path to your MySQL bin dir to $PATH and path to your MySQL lib dir to $DYLD_LIBRARY_PATH.