Cannot call method 'trim' of undefined #2543

Closed
wavded opened this Issue Jun 19, 2012 · 19 comments

Projects

None yet

8 participants

@wavded

Running latest 0.6 and latest NPM (updated today)

npm ERR! System Linux 3.4.3-1-ARCH
npm ERR! command "node" "/usr/local/bin/npm" "update" "-g"
npm ERR! cwd /home/wavded
npm ERR! node -v v0.6.19
npm ERR! npm -v 1.1.29
npm ERR! type non_object_property_call
npm ERR! message Cannot call method 'trim' of undefined
npm ERR! TypeError: Cannot call method 'trim' of undefined
npm ERR!     at readmeDescription (/usr/local/lib/node_modules/npm/node_modules/read-package-json/read-json.js:217:42)
npm ERR!     at final (/usr/local/lib/node_modules/npm/node_modules/read-package-json/read-json.js:297:33)
npm ERR!     at /usr/local/lib/node_modules/npm/node_modules/read-package-json/read-json.js:115:33
npm ERR!     at cb (/usr/local/lib/node_modules/npm/node_modules/slide/lib/async-map.js:48:11)
npm ERR!     at /usr/local/lib/node_modules/npm/node_modules/read-package-json/read-json.js:234:40
npm ERR!     at [object Object].<anonymous> (fs.js:123:5)
npm ERR!     at [object Object].emit (events.js:64:17)
npm ERR!     at fs.js:1190:12
npm ERR!     at Object.oncomplete (/usr/local/lib/node_modules/npm/node_modules/graceful-fs/graceful-fs.js:94:5)
npm ERR!  [TypeError: Cannot call method 'trim' of undefined]
npm ERR! You may report this log at:
npm ERR!     <http://github.com/isaacs/npm/issues>
npm ERR! or email it to:
npm ERR!     <npm-@googlegroups.com>
@adamramadhan

same here! 🍺

811 silly gunzTarPerm extractEntry deps/libiconv/libcharset/NEWS
812 silly gunzTarPerm extractEntry deps/libiconv/libcharset/tools/README
813 silly gunzTarPerm extractEntry deps/libiconv/libcharset/tools/aix-4.1.5
817 silly gunzTarPerm extractEntry deps/libiconv/libcharset/tools/solaris-2.6
818 silly gunzTarPerm extractEntry deps/libiconv/libcharset/tools/darwin-9.5
819 silly gunzTarPerm extractEntry deps/libiconv/libcharset/tools/all-locales
820 silly gunzTarPerm extractEntry deps/libiconv/libcharset/tools/aix-3.2.5
1807 verbose parsed url { pathname: '', path: '', href: '' }
1808 verbose addNamed [ 'yamlish', '
' ]
1809 verbose addNamed [ null, '' ]
1810 silly addNameRange { name: 'yamlish', range: '', hasData: false }
1811 verbose url raw yamlish
1812 verbose url resolving [ 'https://registry.npmjs.org/', './yamlish' ]
1813 verbose url resolved https://registry.npmjs.org/yamlish
1814 verbose etag "IMAZLFMRE2Z7BOYFRA2L43AC"
1815 http GET https://registry.npmjs.org/yamlish
1816 http 304 https://registry.npmjs.org/tap-results
1817 silly registry.get cb [ 304,
1817 silly registry.get { server: 'CouchDB/1.2.0 (Erlang OTP/R15B)',
1817 silly registry.get etag: '"CH0GY1LU5OFYOOTRT0MY16F67"',
1817 silly registry.get date: 'Tue, 19 Jun 2012 15:55:08 GMT',
1817 silly registry.get 'content-length': '0' } ]
1818 verbose etag tap-results from cache
1820 silly addNameRange versions [ 'tap-results', [ '0.0.1', '0.0.2' ] ]
1821 warn deprecated tap-results@0.0.2: this is merged into the 'tap' module now
1822 verbose addRemoteTarball 'a124dfe7a4b66279c6f65aedc54ec5977464268b' ]
1826 silly registry.get etag: '"E6LZ8NAUVXGC0BPT818M2O75U"',
1826 silly registry.get date: 'Tue, 19 Jun 2012 15:55:09 GMT',
1826 silly registry.get 'content-length': '0' } ]
1827 verbose etag inherits from cache
1829 silly registry.get { server: 'CouchDB/1.2.0 (Erlang OTP/R15B)',
1836 verbose read json /root/.npm/yamlish/0.0.5/package/package.json
1840 silly gunzTarPerm modes [ '755', '644' ]
1841 silly gunzTarPerm extractEntry package.json
1842 silly gunzTarPerm extractEntry README.md
1843 silly gunzTarPerm extractEntry results.js
1845 error TypeError: Cannot call method 'trim' of undefined
1840 silly gunzTarPerm modes [ '755', '644' ]
1841 silly gunzTarPerm extractEntry package.json
1842 silly gunzTarPerm extractEntry README.md
1843 silly gunzTarPerm extractEntry results.js
1845 error TypeError: Cannot call method 'trim' of undefined
1845 error at /usr/local/lib/node_modules/npm/node_modules/read-package-json
/read-json.js:115:33
1845 error at cb (/usr/local/lib/node_modules/npm/node_modules/slide/lib/asy
nc-map.js:48:11)
1845 error at /usr/local/lib/node_modules/npm/node_modules/read-package-json
/read-json.js:234:40
1845 error at fs.readFile (fs.js:176:14)
1845 error at fs.close (/usr/local/lib/node_modules/npm/node_modules/gracefu
l-fs/graceful-fs.js:94:5)
1845 error at Object.oncomplete (fs.js:297:15)
1845 error [TypeError: Cannot call method 'trim' of undefined]
1846 error You may report this log at:
1846 error http://github.com/isaacs/npm/issues
1846 error or email it to:
1846 error npm-@googlegroups.com
1847 error System Linux 3.2.20-1.29.6.amzn1.x86_64
1848 error command "node" "/usr/local/bin/npm" "install" "-g" "Haraka"
1849 error cwd /root
1850 error node -v v0.7.12-pre
1851 error npm -v 1.1.29
1852 error type non_object_property_call
1853 error message Cannot call method 'trim' of undefined
1854 verbose exit [ 1, true ]

@isaacs isaacs added a commit to npm/read-package-json that referenced this issue Jun 19, 2012
@isaacs isaacs Don't trim() potentially undefined value fc0ea7f
@isaacs isaacs closed this in 16304e0 Jun 19, 2012
@denro

Just ran your patch and i still get this error:

npm ERR! TypeError: Cannot call method 'trim' of undefined
npm ERR! at readmeDescription (/usr/local/lib/node_modules/npm/node_modules/read-package-json/read-json.js:216:38)
npm ERR! at final (/usr/local/lib/node_modules/npm/node_modules/read-package-json/read-json.js:298:33)
npm ERR! at /usr/local/lib/node_modules/npm/node_modules/read-package-json/read-json.js:115:33
npm ERR! at cb (/usr/local/lib/node_modules/npm/node_modules/slide/lib/async-map.js:48:11)
npm ERR! at /usr/local/lib/node_modules/npm/node_modules/read-package-json/read-json.js:235:40
npm ERR! at [object Object]. (fs.js:123:5)
npm ERR! at [object Object].emit (events.js:64:17)
npm ERR! at fs.js:1190:12
npm ERR! at Object.oncomplete (/usr/local/lib/node_modules/npm/node_modules/graceful-fs/graceful-fs.js:94:5)
npm ERR! [TypeError: Cannot call method 'trim' of undefined]
npm ERR! You may report this log at:
npm ERR! http://github.com/isaacs/npm/issues
npm ERR! or email it to:
npm ERR! npm-@googlegroups.com

npm ERR! System Darwin 11.4.0
npm ERR! command "node" "/usr/local/bin/npm" "install"
npm ERR! cwd /Users/denro/workspace/midasjs
npm ERR! node -v v0.6.19
npm ERR! npm -v 1.1.30
npm ERR! type non_object_property_call
npm ERR! message Cannot call method 'trim' of undefined
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /Users/denro/workspace/midasjs/npm-debug.log
npm ERR! not ok code undefined
npm ERR! not ok code 1

@mridgway

Still seeing with newest version:

$ npm install
npm ERR! TypeError: Cannot call method 'trim' of undefined
npm ERR! at readmeDescription (/usr/local/lib/node_modules/npm/node_modules/read-package-json/read-json.js:217:38)
npm ERR! at final (/usr/local/lib/node_modules/npm/node_modules/read-package-json/read-json.js:299:33)
npm ERR! at /usr/local/lib/node_modules/npm/node_modules/read-package-json/read-json.js:115:33
npm ERR! at cb (/usr/local/lib/node_modules/npm/node_modules/slide/lib/async-map.js:48:11)
npm ERR! at /usr/local/lib/node_modules/npm/node_modules/read-package-json/read-json.js:236:40
npm ERR! at [object Object]. (fs.js:123:5)
npm ERR! at [object Object].emit (events.js:64:17)
npm ERR! at fs.js:1190:12
npm ERR! at Object.oncomplete (/usr/local/lib/node_modules/npm/node_modules/graceful-fs/graceful-fs.js:94:5)
npm ERR! [TypeError: Cannot call method 'trim' of undefined]
npm ERR! You may report this log at:
npm ERR! http://github.com/isaacs/npm/issues
npm ERR! or email it to:
npm ERR! npm-@googlegroups.com

npm ERR! System Darwin 11.4.0
npm ERR! command "node" "/usr/local/bin/npm" "install"
npm ERR! cwd /Users/mike/Projects/derby_app
npm ERR! node -v v0.6.19
npm ERR! npm -v 1.1.31
npm ERR! type non_object_property_call
npm ERR! message Cannot call method 'trim' of undefined
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /Users/mike/Projects/derby_app/npm-debug.log
npm ERR! not ok code undefined
npm ERR! not ok code 1

@siddMahen

@isaacs perhaps this issue should be reopened? I'm having this problem as well.

@denro

Reinstalling Node from the node website fixes all my issues.

I had my node installed by brew, and npm installed with the install shell script.

@adamramadhan

@siddMahen can you post your log in pastebin or gist? i cant reproduce the bug again after the patch.

@siddMahen

Awesome, it seems that after 34d19e2 this has been fixed :) Never mind.

@mridgway

Still having the issue on latest versions (I tried it on latest npm with 0.6 as well, same thing):

~/Projects/derby_app $ npm install
npm ERR! TypeError: Cannot call method 'trim' of undefined
npm ERR!     at readmeDescription (/usr/local/lib/node_modules/npm/node_modules/read-package-json/read-json.js:217:38)
npm ERR!     at final (/usr/local/lib/node_modules/npm/node_modules/read-package-json/read-json.js:299:33)
npm ERR!     at /usr/local/lib/node_modules/npm/node_modules/read-package-json/read-json.js:115:33
npm ERR!     at cb (/usr/local/lib/node_modules/npm/node_modules/slide/lib/async-map.js:48:11)
npm ERR!     at /usr/local/lib/node_modules/npm/node_modules/read-package-json/read-json.js:236:40
npm ERR!     at fs.readFile (fs.js:176:14)
npm ERR!     at fs.close (/usr/local/lib/node_modules/npm/node_modules/graceful-fs/graceful-fs.js:94:5)
npm ERR!     at Object.oncomplete (fs.js:297:15)
npm ERR!  [TypeError: Cannot call method 'trim' of undefined]
npm ERR! You may report this log at:
npm ERR!     <http://github.com/isaacs/npm/issues>
npm ERR! or email it to:
npm ERR!     <npm-@googlegroups.com>

npm ERR! System Darwin 11.4.0
npm ERR! command "node" "/usr/local/bin/npm" "install"
npm ERR! cwd /Users/mike/Projects/derby_app
npm ERR! node -v v0.8.0
npm ERR! npm -v 1.1.32
npm ERR! type non_object_property_call
npm ERR! message Cannot call method 'trim' of undefined
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /Users/mike/Projects/derby_app/npm-debug.log
npm ERR! not ok code 0

I uninstalled node and reinstalled (using homebrew) to get to node version 0.8.

@aharte

Having same issue as @mridgway. Exactly the same message word-for-word. Using node 0.8.0 (having tried 0.6), npm 1.1.32, read-package-json 0.0.11 and System Darwin 11.4.0.

Also using Derby.js (0.3.10) but can't see anything there that's getting in the way. read-package-json is not mentioned in Derby's package.json or bundled in Derby's node_modules.

@zwigby

Also getting this trying to install individual packages.

npm install strata

Relevant info:

npm ERR! node -v v0.8.0
npm ERR! npm -v 1.1.32

Let me know if you need more information.

@isaacs
npm member

@mridgway What is the package.json in the folder where you'er running npm install?

@zwigby @aharte Please post the entire error message (http fetches and all).

Does it work if you do npm cache clean and try again?

I cannot reproduce this, and looking at the code, there's no way that string.split can create an array with undefined members, so... I'm a bit confused.

@mridgway

package.json generated automatically by derbyjs:

{
  "name": "derby_app",
  "description": "",
  "version": "0.0.0",
  "main": "./server.js",
  "dependencies": {
    "derby": "*",
    "express": "3.x",
    "gzippo": ">=0.1.4"
  },
  "private": true
}

npm cache clean does not help in my case. I've uninstalled node and npm as well and tried re-installing node from the node website. Nothing seems to work. I'm as confused as you are.

@mridgway

So I looked into the source of read-package-json, and it looks like the issue is here:

for (var s = 0; d[s].trim().match(/^(#|$)/); s ++); where d = [ '# derby_app' ]

@isaacs isaacs added a commit to npm/read-package-json that referenced this issue Jun 27, 2012
@isaacs isaacs Handle READMEs that are just a heading and nothing more 96130f1
@isaacs
npm member

Having the data to reproduce the problem makes all the difference in the world :)

@denro

derby just had a header on the readme :/

@aharte

npm cache clean does not help in my case either.

To re-create this problem, install derby.js npm install -g derby, then in a suitable directory run derby new project_name.

Also, tried again after updating to read-package-json v0.0.12.

The error message (stored in npm-debug.log) I get, is as follows:

0 info it worked if it ends with ok
1 verbose cli [ 'node', '/usr/local/bin/npm', 'install' ]
2 info using npm@1.1.32
3 info using node@v0.8.0
4 verbose node symlink /usr/local/bin/node
5 verbose config file /Users/aharte/.npmrc
6 verbose config file /usr/local/etc/npmrc
7 verbose config file /usr/local/lib/node_modules/npm/npmrc
8 verbose read json /Users/aharte/Code/derby/project1/package.json
9 error TypeError: Cannot call method 'trim' of undefined
9 error     at readmeDescription (/usr/local/lib/node_modules/npm/node_modules/read-package-json/read-json.js:217:38)
9 error     at final (/usr/local/lib/node_modules/npm/node_modules/read-package-json/read-json.js:299:33)
9 error     at /usr/local/lib/node_modules/npm/node_modules/read-package-json/read-json.js:115:33
9 error     at cb (/usr/local/lib/node_modules/npm/node_modules/slide/lib/async-map.js:48:11)
9 error     at /usr/local/lib/node_modules/npm/node_modules/read-package-json/read-json.js:236:40
9 error     at fs.readFile (fs.js:176:14)
9 error     at fs.close (/usr/local/lib/node_modules/npm/node_modules/graceful-fs/graceful-fs.js:94:5)
9 error     at Object.oncomplete (fs.js:297:15)
9 error  [TypeError: Cannot call method 'trim' of undefined]
10 error You may report this log at:
10 error     <http://github.com/isaacs/npm/issues>
10 error or email it to:
10 error     <npm-@googlegroups.com>
11 error System Darwin 11.4.0
12 error command "node" "/usr/local/bin/npm" "install"
13 error cwd /Users/aharte/Code/derby/project1
14 error node -v v0.8.0
15 error npm -v 1.1.32
16 error type non_object_property_call
17 error message Cannot call method 'trim' of undefined
18 verbose exit [ 1, true ]
@aharte

...and my package.json

{
  "name": "project1",
  "description": "",
  "version": "0.0.0",
  "main": "./server.js",
  "dependencies": {
    "derby": "*",
    "express": "3.x",
    "gzippo": ">=0.1.4"
  },
  "private": true
}
@aharte

@denro @mridgway

After reading @denro's comments about the README.md derby.js creates, I modified it by adding a couple of lines. Running npm install now runs to completion without error.

After looking at this a bit further, it appears that this problem, in my case, is being caused by # character in row 1 col 1 of the file README.md. However, if the README.md contains more than one line, then the presence of the # isn't problematic.

@zwigby

Here is the entire debug log. Cleaning cache did not help.

0 info it worked if it ends with ok
1 verbose cli [ 'node', '/usr/local/bin/npm', 'install', 'strata' ]
2 info using npm@1.1.32
3 info using node@v0.8.0
4 verbose config file /Users/keyce/.npmrc
5 verbose config file /usr/local/etc/npmrc
6 verbose config file /usr/local/lib/node_modules/npm/npmrc
7 verbose read json /Users/keyce/Documents/Projects/modulus/medusa/package.json
8 verbose read json /Users/keyce/Documents/Projects/modulus/medusa/node_modules/async/package.json
9 verbose read json /Users/keyce/Documents/Projects/modulus/medusa/node_modules/aws-lib/package.json
10 verbose read json /Users/keyce/Documents/Projects/modulus/medusa/node_modules/aws-sqs/package.json
11 verbose read json /Users/keyce/Documents/Projects/modulus/medusa/node_modules/modulus-backend-common/package.json
12 verbose read json /Users/keyce/Documents/Projects/modulus/medusa/node_modules/simpledb/package.json
13 verbose read json /Users/keyce/Documents/Projects/modulus/medusa/node_modules/strata/package.json
14 verbose read json /Users/keyce/Documents/Projects/modulus/medusa/node_modules/vows/package.json
15 error TypeError: Cannot call method 'trim' of undefined
15 error at readmeDescription (/usr/local/lib/node_modules/npm/node_modules/read-package-json/read-json.js:217:38)
15 error at final (/usr/local/lib/node_modules/npm/node_modules/read-package-json/read-json.js:299:33)
15 error at /usr/local/lib/node_modules/npm/node_modules/read-package-json/read-json.js:115:33
15 error at cb (/usr/local/lib/node_modules/npm/node_modules/slide/lib/async-map.js:48:11)
15 error at /usr/local/lib/node_modules/npm/node_modules/read-package-json/read-json.js:236:40
15 error at fs.readFile (fs.js:176:14)
15 error at fs.close (/usr/local/lib/node_modules/npm/node_modules/graceful-fs/graceful-fs.js:94:5)
15 error at Object.oncomplete (fs.js:297:15)
15 error [TypeError: Cannot call method 'trim' of undefined]
16 error You may report this log at:
16 error http://github.com/isaacs/npm/issues
16 error or email it to:
16 error npm-@googlegroups.com
17 error System Darwin 11.4.0
18 error command "node" "/usr/local/bin/npm" "install" "strata"
19 error cwd /Users/keyce/Documents/Projects/modulus/medusa
20 error node -v v0.8.0
21 error npm -v 1.1.32
22 error type non_object_property_call
23 error message Cannot call method 'trim' of undefined
24 verbose exit [ 1, true ]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment