anseki / vscode-color

Helper with GUI to generate color codes such as CSS color notations.
MIT License
97 stars 27 forks source link

Error: Cannot find module 'ansi' #10

Closed wjdp closed 8 years ago

wjdp commented 8 years ago

Steps to Reproduce:

  1. Select pick colour in Sass file
  2. No previews and crash when picker chosen. image

image

Log: (Click menu of VS Code "Help > Toggle Developer Tools", and click "Console" tab)

[Extension Host] 
threadService.ts:217[Extension Host] Starting new check on: /home/will/local/history-project/_content/history.md [markdown]
threadService.ts:217[Extension Host] Start child process...
threadService.ts:217[Extension Host] Try to get npm via usage info.
threadService.ts:217[Extension Host] npm directory path: /usr/share/npm
threadService.ts:217[Extension Host] npm path: /usr/share/npm/lib/npm.js
threadService.ts:217[Extension Host] Base directory path: /home/will/.vscode/extensions/anseki.vscode-color-0.1.11
threadService.ts:217[Extension Host] Retry (Error: Cannot find module 'electron-prebuilt')
threadService.ts:217[Extension Host] Try to load: /usr/share/npm/lib/utils/spawn.js
threadService.ts:217[Extension Host] Error: Cannot find module 'ansi'
    at Function.Module._resolveFilename (module.js:339:15)
    at Function.Module._load (module.js:290:25)
    at Function.I.n._load (/usr/share/code/resources/app/out/vs/workbench/node/extensionHostProcess.js:12:25921)
    at Module.require (module.js:367:17)
    at require (internal/module.js:16:19)
    at Object.<anonymous> (/usr/share/npm/lib/ls.js:15:13)
    at Module._compile (module.js:413:34)
    at Object.Module._extensions..js (module.js:422:10)
    at Module.load (module.js:357:32)
    at Function.Module._load (module.js:314:12)(anonymous function) @ threadService.ts:217
messageService.ts:119[processBridge]: Error: Cannot find module 'ansi'
anseki commented 8 years ago

Hi @wjdp, thank you for the report.

It seems that loading ansi module the NPM requires failed. Does your NPM work fine? Please check that the module was installed into /usr/share/npm/node_modules/ansi.

wjdp commented 8 years ago

It's not there. NPM seems to be working fine. I've tried to manually install which has not helped:

[~]$ sudo npm install -g ansi                                                  
/usr/local/lib
`-- ansi@0.3.1 

Still get the same result in vscode

anseki commented 8 years ago

The npmlog module that is a part of NPM depends on the ansi. Then, the ansi should exist in /usr/share/npm/node_modules/npmlog/node_modules/ansi. If that is not there, try:

cd /usr/share/npm/node_modules/npmlog
sudo npm install
anseki commented 8 years ago

BTW, does the issue happen in only SASS files?

wjdp commented 8 years ago

No, any time I try to call any commands this project has added to the command palette. The preview of hex colours does not happen anywhere.

[/usr/share/npm/node_modules/npmlog]$ sudo npm install                         
[sudo] password for will: 
npm WARN deprecated minimatch@2.0.10: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
npmlog@2.0.0 /usr/share/npm/node_modules/npmlog
+-- are-we-there-yet@1.0.4
| `-- readable-stream@1.1.13
|   +-- inherits@2.0.3 
|   +-- isarray@0.0.1 
|   `-- string_decoder@0.10.31 
+-- gauge@1.2.2
| `-- has-unicode@1.0.1 
`-- tap@2.2.1 
  +-- codecov.io@0.1.6 
  | +-- request@2.42.0 
  | | +-- aws-sign2@0.5.0 
  | | +-- bl@0.9.5 
  | | | `-- readable-stream@1.0.34 
  | | +-- caseless@0.6.0 
  | | +-- forever-agent@0.5.2 
  | | +-- form-data@0.1.4 
  | | | +-- async@0.9.2 
  | | | +-- combined-stream@0.0.7 
  | | | | `-- delayed-stream@0.0.5 
  | | | `-- mime@1.2.11 
  | | +-- hawk@1.1.1 
  | | | +-- boom@0.4.2 
  | | | +-- cryptiles@0.2.2 
  | | | +-- hoek@0.9.1 
  | | | `-- sntp@0.2.4 
  | | +-- http-signature@0.10.1 
  | | | +-- asn1@0.1.11 
  | | | +-- assert-plus@0.1.5 
  | | | `-- ctype@0.5.3 
  | | +-- json-stringify-safe@5.0.1 
  | | +-- mime-types@1.0.2 
  | | +-- node-uuid@1.4.7 
  | | +-- oauth-sign@0.4.0 
  | | +-- qs@1.2.2 
  | | +-- stringstream@0.0.5 
  | | +-- tough-cookie@2.3.1 
  | | `-- tunnel-agent@0.4.3 
  | `-- urlgrey@0.4.0 
  |   `-- tape@2.3.0 
  |     +-- deep-equal@0.1.2 
  |     +-- defined@0.0.0 
  |     +-- jsonify@0.0.0 
  |     +-- resumer@0.0.0 
  |     +-- split@0.2.10 
  |     +-- stream-combiner@0.0.4 
  |     | `-- duplexer@0.1.1 
  |     `-- through@2.3.8 
  +-- coveralls@2.11.14 
  | +-- lcov-parse@0.0.10 
  | +-- log-driver@1.2.5 
  | +-- minimist@1.2.0 
  | `-- request@2.75.0 
  |   +-- aws-sign2@0.6.0 
  |   +-- aws4@1.4.1 
  |   +-- bl@1.1.2 
  |   | `-- readable-stream@2.0.6 
  |   |   `-- isarray@1.0.0 
  |   +-- caseless@0.11.0 
  |   +-- combined-stream@1.0.5 
  |   | `-- delayed-stream@1.0.0 
  |   +-- extend@3.0.0 
  |   +-- forever-agent@0.6.1 
  |   +-- form-data@2.0.0 
  |   | `-- asynckit@0.4.0 
  |   +-- har-validator@2.0.6 
  |   | +-- chalk@1.1.3 
  |   | | +-- ansi-styles@2.2.1 
  |   | | +-- has-ansi@2.0.0 
  |   | | `-- supports-color@2.0.0 
  |   | +-- commander@2.9.0 
  |   | | `-- graceful-readlink@1.0.1 
  |   | +-- is-my-json-valid@2.14.0 
  |   | | +-- generate-function@2.0.0 
  |   | | +-- generate-object-property@1.2.0 
  |   | | | `-- is-property@1.0.2 
  |   | | +-- jsonpointer@2.0.0 
  |   | | `-- xtend@4.0.1 
  |   | `-- pinkie-promise@2.0.1 
  |   |   `-- pinkie@2.0.4 
  |   +-- hawk@3.1.3 
  |   | +-- boom@2.10.1 
  |   | +-- cryptiles@2.0.5 
  |   | +-- hoek@2.16.3 
  |   | `-- sntp@1.0.9 
  |   +-- http-signature@1.1.1 
  |   | +-- assert-plus@0.2.0 
  |   | +-- jsprim@1.3.1 
  |   | | +-- extsprintf@1.0.2 
  |   | | +-- json-schema@0.2.3 
  |   | | `-- verror@1.3.6 
  |   | `-- sshpk@1.10.0 
  |   |   +-- asn1@0.2.3 
  |   |   +-- assert-plus@1.0.0 
  |   |   +-- bcrypt-pbkdf@1.0.0 
  |   |   | `-- tweetnacl@0.14.3 
  |   |   +-- dashdash@1.14.0 
  |   |   | `-- assert-plus@1.0.0 
  |   |   +-- ecc-jsbn@0.1.1 
  |   |   +-- getpass@0.1.6 
  |   |   | `-- assert-plus@1.0.0 
  |   |   +-- jodid25519@1.0.2 
  |   |   +-- jsbn@0.1.0 
  |   |   `-- tweetnacl@0.13.3 
  |   +-- is-typedarray@1.0.0 
  |   +-- isstream@0.1.2 
  |   +-- mime-types@2.1.12 
  |   | `-- mime-db@1.24.0 
  |   +-- oauth-sign@0.8.2 
  |   `-- qs@6.2.1 
  +-- deep-equal@1.0.1 
  +-- deeper@2.1.0 
  +-- foreground-child@1.5.3 
  | +-- cross-spawn@4.0.2 
  | | +-- lru-cache@4.0.1 
  | | | +-- pseudomap@1.0.2 
  | | | `-- yallist@2.0.0 
  | | `-- which@1.2.11 
  | |   `-- isexe@1.1.2 
  | `-- signal-exit@3.0.1 
  +-- glob@5.0.15 
  | +-- inflight@1.0.5 
  | | `-- wrappy@1.0.2 
  | +-- minimatch@3.0.3 
  | | `-- brace-expansion@1.1.6 
  | |   +-- balanced-match@0.4.2 
  | |   `-- concat-map@0.0.1 
  | +-- once@1.4.0 
  | `-- path-is-absolute@1.0.0 
  +-- js-yaml@3.6.1 
  | +-- argparse@1.0.7 
  | | `-- sprintf-js@1.0.3 
  | `-- esprima@2.7.3 
  +-- mkdirp@0.5.1 
  | `-- minimist@0.0.8 
  +-- nyc@3.2.2 
  | +-- foreground-child@1.3.0  (git+https://github.com/bcoe/foreground-child.git#ad7ba1d4a84e8b199cbfb5d30e01e586390978cc)
  | | `-- win-spawn@2.0.0 
  | +-- istanbul@0.3.22 
  | | +-- abbrev@1.0.9 
  | | +-- async@1.5.2 
  | | +-- escodegen@1.7.1 
  | | | +-- esprima@1.2.5 
  | | | +-- estraverse@1.9.3 
  | | | +-- esutils@2.0.2 
  | | | +-- optionator@0.5.0 
  | | | | +-- deep-is@0.1.3 
  | | | | +-- fast-levenshtein@1.0.7 
  | | | | +-- levn@0.2.5 
  | | | | +-- prelude-ls@1.1.2 
  | | | | +-- type-check@0.3.2 
  | | | | `-- wordwrap@0.0.3 
  | | | `-- source-map@0.2.0 
  | | |   `-- amdefine@1.0.0 
  | | +-- esprima@2.5.0 
  | | +-- fileset@0.2.1 
  | | | `-- minimatch@2.0.10 
  | | +-- handlebars@4.0.5 
  | | | +-- async@1.5.2 
  | | | +-- optimist@0.6.1 
  | | | | +-- minimist@0.0.10 
  | | | | `-- wordwrap@0.0.3 
  | | | +-- source-map@0.4.4 
  | | | `-- uglify-js@2.7.3 
  | | |   +-- async@0.2.10 
  | | |   +-- source-map@0.5.6 
  | | |   +-- uglify-to-browserify@1.0.2 
  | | |   `-- yargs@3.10.0 
  | | |     +-- camelcase@1.2.1 
  | | |     +-- cliui@2.1.0 
  | | |     | +-- center-align@0.1.3 
  | | |     | | +-- align-text@0.1.4 
  | | |     | | | +-- kind-of@3.0.4 
  | | |     | | | | `-- is-buffer@1.1.4 
  | | |     | | | +-- longest@1.0.1 
  | | |     | | | `-- repeat-string@1.5.4 
  | | |     | | `-- lazy-cache@1.0.4 
  | | |     | +-- right-align@0.1.3 
  | | |     | `-- wordwrap@0.0.2 
  | | |     `-- window-size@0.1.0 
  | | +-- nopt@3.0.6 
  | | +-- resolve@1.1.7 
  | | +-- supports-color@3.1.2 
  | | | `-- has-flag@1.0.0 
  | | `-- wordwrap@1.0.0 
  | +-- lodash@3.10.1 
  | +-- rimraf@2.5.4 
  | | `-- glob@7.1.0 
  | +-- spawn-wrap@1.0.1  (git+https://github.com/bcoe/spawn-wrap.git#aa0c61536567be2bacb91cba5a786c9044ae65ea)
  | | `-- os-homedir@1.0.1 
  | +-- strip-bom@2.0.0 
  | | `-- is-utf8@0.2.1 
  | `-- yargs@3.32.0 
  |   +-- camelcase@2.1.1 
  |   +-- cliui@3.2.0 
  |   | `-- wrap-ansi@2.0.0 
  |   +-- decamelize@1.2.0 
  |   +-- os-locale@1.4.0 
  |   | `-- lcid@1.0.0 
  |   |   `-- invert-kv@1.0.0 
  |   +-- string-width@1.0.2 
  |   | +-- code-point-at@1.0.0 
  |   | | `-- number-is-nan@1.0.0 
  |   | `-- is-fullwidth-code-point@1.0.0 
  |   +-- window-size@0.1.4 
  |   `-- y18n@3.2.1 
  +-- only-shallow@1.2.0 
  +-- opener@1.4.2 
  +-- readable-stream@2.1.5 
  | +-- buffer-shims@1.0.0 
  | +-- core-util-is@1.0.2 
  | +-- isarray@1.0.0 
  | +-- process-nextick-args@1.0.7 
  | +-- string_decoder@0.10.31 
  | `-- util-deprecate@1.0.2 
  +-- signal-exit@2.1.2 
  +-- supports-color@1.3.1 
  +-- tap-mocha-reporter@0.0.27 
  | +-- color-support@1.1.1 
  | +-- debug@2.2.0 
  | | `-- ms@0.7.1 
  | +-- diff@1.4.0 
  | +-- escape-string-regexp@1.0.5 
  | +-- glob@7.1.0 
  | | `-- fs.realpath@1.0.0 
  | +-- readable-stream@1.1.14 
  | | `-- isarray@0.0.1 
  | `-- unicode-length@1.0.3 
  |   +-- punycode@1.4.1 
  |   `-- strip-ansi@3.0.1 
  |     `-- ansi-regex@2.0.0 
  +-- tap-parser@1.3.2 
  | `-- events-to-array@1.0.2 
  `-- tmatch@1.0.2 

[/usr/share/npm/node_modules/npmlog]$ ls node_modules/ansi                     
examples  History.md  lib  package.json  README.md

However after restarting vscode I'm still getting:

[processBridge]: Error: Cannot find module 'ansi'

anseki commented 8 years ago

Ummm... I'm still looking for clues.

This issue is reported first time. I tried installing Node.js v4.2.6 and NPM v3.5.2 in Ubuntu, then the extension works fine. And also other environments.

wjdp commented 8 years ago

Done all this so far on my laptop. Just switched to desktop (Also Ubuntu 16.04) which does not have a vscode install on it. Installed latest and then colour picker plugin before anything else. Ctrl+Shift+P "Pick Colour", exact same result.

threadService.ts:217[Extension Host] Start child process...
threadService.ts:217[Extension Host] Try to get npm via usage info.
threadService.ts:217[Extension Host] npm directory path: /usr/share/npm
threadService.ts:217[Extension Host] npm path: /usr/share/npm/lib/npm.js
threadService.ts:217[Extension Host] Base directory path: /home/will/.vscode/extensions/anseki.vscode-color-0.1.11
threadService.ts:217[Extension Host] Retry (Error: Cannot find module 'electron-prebuilt')
threadService.ts:217[Extension Host] Try to load: /usr/share/npm/lib/utils/spawn.js
threadService.ts:217[Extension Host] Error: Cannot find module 'ansi'
    at Function.Module._resolveFilename (module.js:339:15)
    at Function.Module._load (module.js:290:25)
    at Function.I.n._load (/usr/share/code/resources/app/out/vs/workbench/node/extensionHostProcess.js:12:25921)
    at Module.require (module.js:367:17)
    at require (internal/module.js:16:19)
    at Object.<anonymous> (/usr/share/npm/lib/ls.js:15:13)
    at Module._compile (module.js:413:34)
    at Object.Module._extensions..js (module.js:422:10)
    at Module.load (module.js:357:32)
    at Function.Module._load (module.js:314:12)(anonymous function) @ threadService.ts:217
messageService.ts:119[processBridge]: Error: Cannot find module 'ansi'

Could be my NPM installs, will have a look later.

(Thanks for all the help/attention so far!)

anseki commented 8 years ago

That log also said that the error occurred in /usr/share/npm/lib/ls.js:15. Could you show me the line #15 of /usr/share/npm/lib/ls.js?

Since Node.js v4.2.6 includes NPM v2.14.12, you might have updated NPM to v3.5.2. The old version might still exist in your computer, and it might have made the trouble. Or, if you use a npmrc file, it might have made the trouble.

epoweripione commented 8 years ago

not the same,have been move to #7

anseki commented 8 years ago

Hi @epoweripione, That seems be not same error. This issue is "Error: Cannot find module 'ansi'", your case is "Error: ENOENT: no such file or directory, open...". It seems that this is a duplicate of #7. Please comment again to that issue.

anseki commented 8 years ago

No reply came, and I close this issue.

SonyaHon commented 7 years ago

Hello, know post is closed but still. Had the same problem. Iv deleted nodejs and npm, and installed them not from standart ubuntu reppos but with this ones: https://nodejs.org/en/download/package-manager/#debian-and-ubuntu-based-linux-distributions

After doing: sudo apt-get remove nodejs npm curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash - sudo apt-get install -y nodejs Color picker works fine after reinstalling it.

SonyaHon commented 7 years ago

And btw sry for my english.

anseki commented 7 years ago

Hi @SonyaHon, thank you for the report. Yes, this issue occurs when the NPM doesn't work. The Color Picker requires the NPM.

SonyaHon commented 7 years ago

@anseki, as i understood it requires npm version 3.10.10, and it will not work with 3.5.2

anseki commented 7 years ago

I made sure that it works with NPM v2.*. Of course it works with v3.5.2 also. Your NPM v3.5.2 might have been broken. Some NPM commands seem to be working even if the NPM is broken. As everyone knows, since NPM is updated frequently, multiple versions often conflict.

mizusu commented 7 years ago

Had this problem too.

I think it was caused because I had a nodejs (I think its legacy) and the node commands on the terminal, which were using different versions. I fixed it by removing nodejs (sudo apt-get remove nodejs) and using nvm to install the latest LTS version of nodejs (v6.10.3) which is using the 3.10.10 version of npm.

I'm using Ubuntu 16.04 by the way :)

anseki commented 7 years ago

Hi @mizusu, thank you for the report 😄 Yes, that error message should be solved by re-installing Node.js and NPM.

facsa79 commented 7 years ago

The same problem with npm 3.5.2 Color picker works fine after: npm install -g npm (as root)

anseki commented 7 years ago

Hi @facsa79, thank you for the report. It seems that your NPM was broken.

wise1993 commented 5 years ago

Had this problem too.

I think it was caused because I had a nodejs (I think its legacy) and the node commands on the terminal, which were using different versions. I fixed it by removing nodejs (sudo apt-get remove nodejs) and using nvm to install the latest LTS version of nodejs (v6.10.3) which is using the 3.10.10 version of npm.

I'm using Ubuntu 16.04 by the way :)

Thanks for this, it really helped. All i needed do is remove the nodejs and installing the latest version as of the time am doing this >>>

Using Ubuntu

sudo apt-get remove nodejs curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash - sudo apt-get install -y nodejs you can also check out this link for more info https://github.com/nodesource/distributions/blob/master/README.md

anseki commented 5 years ago

Hi @wise1993, thank you for your report. :smile:

ghost commented 5 years ago

I solved this issue by uninstalling react-scripts and installing them again :)

anseki commented 5 years ago

Hi @vnkt66, thank you for your report. :smile: I don't know what effect the react-scripts has in your environment, but this issue occurs when the NPM doesn't work.

aacassandra commented 4 years ago

im solving this with installing node with nvm. im using ubuntu 18.04

anseki commented 4 years ago

Hi @aacassandra, thank you for your report. :smile: Your NPM was fixed maybe.