Code Monkey home page Code Monkey logo

Comments (9)

ajlopez avatar ajlopez commented on September 25, 2024 1

Well, I put

"test": "echo %PATH%"

and run

npm test

but the path is just the original one. No node_modules.bin added

I'm using npm 1.1.0-beta-4
packed into node for windows 0.6.6
in this machine.

Ok, I just upgrade to the latest windows stable version
node v0.6.18
npm 1.1.21

and voila!

the echo %PATH% shows the local node_modules .bin added to PATH!!!

Thanks for your help. I used the old version node/npm for month, wo/major glitches. But with the new version, it's all ok!

(In Windows .msi (installation file), node AND npm are installed, together)

from json5.

MaxNanasy avatar MaxNanasy commented on September 25, 2024

npm test worked for me on Windows 7 using commit b511ff4 in branch develop. I had to run npm install first.

npm link was also not supported for me in Windows.

from json5.

ajlopez avatar ajlopez commented on September 25, 2024

I tried again, in another machine, now with Windows 7. Same issue (I ran npm install, to get mocha, in my first attempt, too). I got the last develop commit (the one mentioned by Max, now)

Apparently, it not recognize "mocha ... " as an executable.

I could run the test manually with

node test\via-eval.js

without glitches.

This is the npm log after npm test, if helps:

info it worked if it ends with ok
verbose cli [ 'C:\Program Files (x86)\nodejs\node.exe',
verbose cli 'C:\Program Files (x86)\nodejs\node_modules\npm\bin\npm-cli.js',
verbose cli 'test' ]
info using [email protected]
info using [email protected]
verbose config file C:\Users\angel.npmrc
verbose config file C:\Program Files (x86)\nodejs\etc\npmrc
verbose config file C:\Program Files (x86)\nodejs\node_modules\npm\npmrc
verbose caching D:\Git\json5\package.json
verbose loadDefaults [email protected]
verbose run-script [ 'pretest', 'test', 'posttest' ]
info pretest [email protected]
info test [email protected]
verbose unsafe-perm in lifecycle true
silly exec cmd "/c" "mocha --ui exports --reporter list"
silly spawning [ 'cmd',
silly spawning [ '/c', 'mocha --ui exports --reporter list' ],
silly spawning 'D:\Git\json5' ]
info [email protected] Failed to exec test script
ERR! [email protected] test: mocha --ui exports --reporter list
ERR! cmd "/c" "mocha --ui exports --reporter list" failed with 1
ERR!
ERR! Failed at the [email protected] test script.
ERR! This is most likely a problem with the json5 package,
ERR! not with npm itself.
ERR! Tell the author that this fails on your system:
ERR! mocha --ui exports --reporter list
ERR! You can get their info via:
ERR! npm owner ls json5
ERR! There is likely additional logging output above.
ERR!
ERR! System Windows_NT 6.1.7600
ERR! command "C:\Program Files (x86)\nodejs\node.exe" "C:\Program Files (x86)\nodejs\node_modules\npm\bin\npm-cli.js" "test"
ERR! cwd D:\Git\json5
ERR! node -v v0.6.6
ERR! npm -v 1.1.0-beta-4
ERR! code ELIFECYCLE
ERR! message [email protected] test: mocha --ui exports --reporter list
ERR! message cmd "/c" "mocha --ui exports --reporter list" failed with 1
verbose exit [ 1, true ]

from json5.

aseemk avatar aseemk commented on September 25, 2024

Thanks guys for raising this issue.

I wasn't aware that npm link doesn't work on Windows; I'll update the documentation. (npm install is actually all that's needed, but npm link does that plus symlink it globally if you want to use it elsewhere. Not a requirement.)

@ajlopez, it's good to know that node test\via-eval runs without a hitch, but that doesn't actually run the tests — it just defines them. It seems the problem is running Mocha.

Could you try running Mocha directly? Install it globally first via npm install -g mocha, then run mocha --ui exports --reporter list?

from json5.

ajlopez avatar ajlopez commented on September 25, 2024

Great!

npm install -g mocha

did the trick in my Windows 7 box!

I don't need npm link, yet. But I could emulate it (in other projects, to reference my local json5 project) using mklink Windows command (I guess)

from json5.

aseemk avatar aseemk commented on September 25, 2024

Great! But that made me realize what may be up -- Mocha was never installed locally, I'm guessing. If you run npm ls in the project directory, does it show anything?

If not, just run npm install (I updated the documentation to list this instead of npm link), then npm should be able to find the local mocha binary just fine. You can choose to npm uninstall -g mocha if you like then.

from json5.

ajlopez avatar ajlopez commented on September 25, 2024

Mocha was installed locally, since my first attempt. But I don't know why it doesn't run from npm test.

I just run npm ls, and mocha is there.
I checked local node_modules, too.
All mocha is there.

Just to be sure, now I did:

npm uninstall -g mocha
npm test

and the issue was back: error, "mocha .... " was not recognized as executable.

A bit of research:

In windows, npm -g install the program at
\AppData\Roaming\npm
Mocha put mocha.cmd at that folder
The machine PATH has an item pointing to that folder (I guess it was put there by node installer for windows).
So, mocha is recognized as command from any folder.

But with local install of mocha, that mocha.cmd is at local node_modules.bin

I don't know if npm includes that local folder in a temporary PATH when it launches test scripts.

But apparently, it doesn't work in my machines.

When I run from local project folder:

node_modules.bin\mocha --ui exports --reporter list

it works (wo/global mocha install)

from json5.

aseemk avatar aseemk commented on September 25, 2024

Interesting. Npm is indeed supposed to include local binaries in the PATH when running scripts like npm test.

Could you echo %PATH% and see what it says? Could you also print the contents of node_modules\.bin?

from json5.

aseemk avatar aseemk commented on September 25, 2024

Ah, that's awesome! Great to hear.

from json5.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.