1

This is me trying to pull a package with regular install:

PS C:\temp> npm install aws-sam-local

> aws-sam-local@0.2.4 postinstall C:\temp\node_modules\aws-sam-local
> go-npm install

Downloading from URL: https://github.com/awslabs/aws-sam-local/releases/download/v0.2.4/sam_0.2.4_windows_amd64.tar.gz
fs.js:766
  return binding.rename(pathModule._makeLong(oldPath),
                 ^

Error: ENOENT: no such file or directory, rename 'C:\temp\node_modules\aws-sam-local\bin\sam.exe' -> 'C:\temp\node_modul
es\aws-sam-local\node_modules\.bin\sam.exe'
    at Object.fs.renameSync (fs.js:766:18)
    at C:\temp\node_modules\go-npm\bin\index.js:62:12
    at C:\temp\node_modules\go-npm\bin\index.js:51:9
    at ChildProcess.exithandler (child_process.js:267:7)
    at emitTwo (events.js:126:13)
    at ChildProcess.emit (events.js:214:7)
    at maybeClose (internal/child_process.js:925:16)
    at Socket.stream.socket.on (internal/child_process.js:346:11)
    at emitOne (events.js:116:13)
    at Socket.emit (events.js:211:7)
npm WARN enoent ENOENT: no such file or directory, open 'C:\temp\package.json'
npm WARN temp No description
npm WARN temp No repository field.
npm WARN temp No README data
npm WARN temp No license field.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! aws-sam-local@0.2.4 postinstall: `go-npm install`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the aws-sam-local@0.2.4 postinstall 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\meee\AppData\Roaming\npm-cache\_logs\2018-01-19T16_14_18_418Z-debug.log

With global:

PS C:\temp> npm install --global aws-sam-local

> aws-sam-local@0.2.4 postinstall C:\Users\meee\AppData\Roaming\npm\node_modules\aws-sam-local
> go-npm install

Downloading from URL: https://github.com/awslabs/aws-sam-local/releases/download/v0.2.4/sam_0.2.4_windows_amd64.tar.gz
+ aws-sam-local@0.2.4
added 72 packages in 48.359s

Why is this broken and how can I pull this package to a specific folder that all users can access? I guess some of my confusion is what "global" even means here because its still installing it to MY user's folders.

red888
  • 27,709
  • 55
  • 204
  • 392

1 Answers1

2

You have no package.json: no such file or directory, open 'C:\temp\package.json'

To install packages locally you need a package.json in your working directory to keep track of your local dependencies. You can create a package.json with npm init.

Read here to get an understanding about global and local packages:

globally - This drops modules in {prefix}/lib/node_modules, and puts executable files in {prefix}/bin, where {prefix} is usually something like /usr/local. It also installs man pages in {prefix}/share/man, if they’re supplied.

locally - This installs your package in the current working directory. Node modules go in ./node_modules, executables go in ./node_modules/.bin/, and man pages aren’t installed at all.

And also How to Install Global Packages? and How to Install Local Packages?

Edit:

pzaenger
  • 11,381
  • 3
  • 45
  • 46
  • where is my global package.json on windows? – red888 Jan 19 '18 at 16:33
  • Right but I assume there is some global package.json which is why the global command is not failing? Where is that global package config? If I go into my global location `C:\Users\mee\AppData\Roaming\npm` I see individual package.json files for each module. How can global create those for me but running the command non-globally cannot? Does global automate the process of running npm init? – red888 Jan 19 '18 at 16:40
  • Mmh. Good question. I searched a lot but couldn't find further information about how npm keep track of global packages. – pzaenger Jan 19 '18 at 17:24