Google Cloud: Create A Simple Application With the API samples npm install failed - node.js

Following the instruction from here, https://cloud.google.com/bigquery/create-simple-app-api
cd to the samples folder
https://github.com/googleapis/nodejs-bigquery/tree/master/samples
The package.json is
https://github.com/googleapis/nodejs-bigquery/blob/master/samples/package.json
{
"name": "nodejs-docs-samples-bigquery",
"version": "0.0.1",
"private": true,
"license": "Apache-2.0",
"author": "Google LLC",
"repository": "googleapis/nodejs-bigquery",
"engines": {
"node": ">=4"
},
"scripts": {
"test": "repo-tools test run --cmd npm -- run cover",
"ava": "ava -T 3m --verbose test/*.test.js system-test/*.test.js",
"cover": "nyc --reporter=lcov --cache ava -T 3m --verbose test/*.test.js system-test/*.test.js && nyc report"
},
"dependencies": {
"#google-cloud/bigquery": "1.2.0",
"#google-cloud/storage": "1.5.1",
"yargs": "10.0.3"
},
"devDependencies": {
"#google-cloud/nodejs-repo-tools": "2.1.3",
"ava": "0.24.0",
"nyc": "11.3.0",
"proxyquire": "1.8.0",
"sinon": "4.1.3",
"uuid": "3.1.0"
}
}
I run
npm install
I get errors
Home-iMac:samples user1$ npm install
npm WARN #google-cloud/bigquery#1.2.0 had bundled packages that do not match the required version(s). They have been replaced with non-bundled versions.
npm ERR! path /Users/user1/project1/gcp/nodejs/bigquery_api/nodejs-bigquery-test/samples/node_modules/.staging/#google-cloud/bigquery-78ee5bef/node_modules/#sindresorhus/is
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall rename
npm ERR! enoent ENOENT: no such file or directory, rename '/Users/user1/project1/gcp/nodejs/bigquery_api/nodejs-bigquery-test/samples/node_modules/.staging/#google-cloud/bigquery-78ee5bef/node_modules/#sindresorhus/is' -> '/Users/user1/project1/gcp/nodejs/bigquery_api/nodejs-bigquery-test/samples/node_modules/.staging/#sindresorhus/is-79439449'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/user1/.npm/_logs/2018-04-27T19_38_14_391Z-debug.log
To fix the error, a hack solution is instead of using the package.json to install, I have to run this manually first
npm install --save #google-cloud/bigquery
Then I can run
npm install
again. This time, it will finish without problem.
But I would like to be able to just simply using package.json, using npm install only to install the packages.
I changed the package.json
From
"#google-cloud/bigquery": "1.2.0",
to
"#google-cloud/bigquery": "^1.2.0",
It still does not work.
Thanks!

#Tim - Thanks for the request to update, #google/bigquery 1.3.0 is being used for the example. The download link to the GitHub site was updated, but the sample code on the page itself is not updated.

Related

Could not resolve dependency with sanity in nextjs app

I am trying to deploy my next.js project, but I keep getting the following error with everything I do:
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: rcd_drone#0.1.0
npm ERR! Found: #sanity/client#3.4.1
npm ERR! node_modules/#sanity/client
npm ERR! #sanity/client#"^3.2.0" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer #sanity/client#"^2.11.0" from next-sanity-image#3.2.1
npm ERR! node_modules/next-sanity-image
npm ERR! next-sanity-image#"^3.2.1" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
I also have the following dependencies:
{
"name": "rcd_drone",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint"
},
"dependencies": {
"#babel/core": "^7.17.9",
"#sanity/client": "^3.2.0",
"#sanity/image-url": "^1.0.1",
"#stripe/stripe-js": "^1.25.0",
"canvas-confetti": "^1.5.1",
"next": "^12.1.0",
"next-sanity-image": "^3.2.1",
"react": "17.0.2",
"react-dom": "17.0.2",
"react-hot-toast": "^2.2.0",
"react-icons": "^4.3.1",
"frontmatter-markdown-loader": "^3.6.3",
"stripe": "^8.209.0"
},
"devDependencies": {
"#babel/preset-react": "^7.16.7",
"eslint": "8.13.0",
"eslint-config-next": "12.1.4"
}
}
Try doing the npm install --legacy-peer-deps within the Vercel project deploy page.
When deploying your project, go to the "build and output" settings, then in the npm command input write: npm install --legacy-peer-deps.
Select the override radio button, then try deploying.
Try deleting node_modules folder and package-lock.json file and run:
npm install --legacy-peer-deps
This is going to make fresh installation of the modules.

'.' is not recognized as an internal or external command (when running npm install for firebaseUI)

I cannot install npm packages on my firebaseUI demo application.
I cloned the master branch on github and am simply trying to run "npm install" but I am getting an error I have never come across with node package manager. I get
'.' is not recognized as an internal or external command
I also tried this will cygwin64 and had the exact same result. below is the error, and below that is my package.json
firebaseui#3.3.0 generate-test-files C:\repos\Firebase Demos\firebaseui-web
> ./buildtools/generate_test_files.sh
'.' is not recognized as an internal or external command,
operable program or batch file.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! firebaseui#3.3.0 generate-test-files: `./buildtools/generate_test_files.sh`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the firebaseui#3.3.0 generate-test-files 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\adam\AppData\Roaming\npm-cache\_logs\2018-08-18T01_43_27_526Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! firebaseui#3.3.0 test: `npm run build && npm run generate-test-files && ./buildtools/run_tests.sh`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the firebaseui#3.3.0 test 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\adam\AppData\Roaming\npm-cache\_logs\2018-08-18T01_43_27_547Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! firebaseui#3.3.0 prepublish: `npm run test && cp -r dist demo/public`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the firebaseui#3.3.0 prepublish 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\adam\AppData\Roaming\npm-cache\_logs\2018-08-18T01_43_27_577Z-debug.log
package.json
{
"name": "firebaseui",
"version": "3.3.0",
"description": "Javascript library for customizable UI on top of Firebase SDK",
"files": [
"dist/firebaseui.js",
"dist/firebaseui.css",
"dist/npm.js",
"dist/index.d.ts",
"dist/externs",
"LICENSE",
"README.md",
"package.json"
],
"main": "./dist/npm.js",
"types": "./dist/index.d.ts",
"style": "dist/firebaseui.css",
"scripts": {
"build": "gulp",
"build-all": "gulp build-all",
"build-soy": "gulp build-soy",
"demo": "npm run build && ./buildtools/run_demo.sh",
"test": "npm run build && npm run generate-test-files && ./buildtools/run_tests.sh",
"serve": "npm run build && npm run generate-test-files && gulp serve",
"generate-test-files": "./buildtools/generate_test_files.sh",
"prepublish": "npm run test && cp -r dist demo/public"
},
"test": "npm run test",
"author": "Google",
"repository": {
"type": "git",
"url": "https://github.com/firebase/firebaseui-web.git"
},
"license": "Apache-2.0",
"devDependencies": {
"closure-builder": "^2.2.34",
"firebase": "^5.0.0",
"firebase-tools": "^4.0.1",
"fs-extra": "^3.0.1",
"google-closure-compiler": "^20171112.0.0",
"google-closure-library": "^20171112.0.0",
"google-closure-templates": "^20150410.0.0",
"gulp": "^4.0.0",
"gulp-clean-css": "^2.0.12",
"gulp-closure-compiler": "^0.4.0",
"gulp-concat-css": "^3.1.0",
"gulp-connect": "^5.5.0",
"gulp-css-flip": "^0.4.0",
"gulp-css-inline-images": "^0.1.1",
"gulp-sass": "^2.3.2",
"gulp-util": "^3.0.7",
"material-design-lite": "^1.2.0",
"protractor": "^5.3.2",
"streamqueue": "^1.1.1"
},
"dependencies": {
"dialog-polyfill": "^0.4.7"
},
"peerDependencies": {
"firebase": ">=5.0.0"
}
}
Although this question is old I ran into the same problem when I was collaborating with another developer using another OS (Linux x Windows).
At the beginning of the project a script .sh was failing depending on the OS. We had to constantly modify the json file after merging some branch.
The solution we came up with was to append the shell being used to call the script, e.g. we changed the initialization script to
...
{
start: bash ./myscript && npm run start
}
...
It works fine on Linux and on Gitbash on Windows.
> ./buildtools/generate_test_files.sh
here just leave out dot-slash(./)
Though, if you wanted to, you could use .\\ (since single '\' would skip the next character) and it would work.

Publish npm, and after installation on other PC have error

and then install it on other pc to check. Bu after install package and it depencies i have error when try to start it
pm ERR! Linux 4.10.0-38-generic
npm ERR! argv "/home/pavlo/.nvm/versions/node/v6.11.4/bin/node" "/home/pavlo/.nvm/versions/node/v6.11.4/bin/npm" "start" "storjboard"
npm ERR! node v6.11.4
npm ERR! npm v3.10.10
npm ERR! path /home/pavlo/Desktop/test/package.json
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall open
npm ERR! enoent ENOENT: no such file or directory, open '/home/pavlo/Desktop/test/package.json'
npm ERR! enoent ENOENT: no such file or directory, open '/home/pavlo/Desktop/test/package.json'
npm ERR! enoent This is most likely not a problem with npm itself
npm ERR! enoent and is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! Please include the following file with any support request:
npm ERR! /home/pavlo/Desktop/test/npm-debug.log
Problem it that i have to clone package.json from git , how i can publish correctly with package.json?
Note: command start inside package.json scripts
My json for publish:
{
"name": "name",
"version": "0.0.3",
"description": "Name",
"main": "script.js",
"dependencies": {
"request": "^2.83.0",
},
"devDependencies": {},
"scripts": {
"test": "mocha",
"start": "node node_modules/module/script.js"
},
"repository": {
"type": "git",
"url": "https://github.com/me/module"
},
"keywords": [
"somewords"
],
"author": "me",
"license": "MIT",
"bugs": {
"url": "https://github.com/me/module/issues"
},
"homepage": "https://github.com/me/module#readme"
}
Error (WARN) when installing module on other PC
npm WARN enoent ENOENT: no such file or directory, open '/home/pavlo/Desktop/test/package.json'
npm WARN test No description
npm WARN test No repository field.
npm WARN test No README data
npm WARN test No license field.
But in test/node_modules/module/(here there are everything) readme, json and script
If you want to be able to start your module from another directory, you can do it like this:
In your module package.json
{
"name": "module",
"scripts": {
"start": "node script.js"
}
}
from the test directory (as this answer suggest):
npm start --prefix node_modules/module/
Alternately, you can start your module by creating a package.json file in your test directory and adding a script:
{
"name": "test",
"scripts": {
"start": "node node_modules/module/script.js"
}
}
Usally npm packages are placed in node_modules directory because those modules are supposed to be used as dependencies, not directly.
It depends on the purpose of your application, but maybe you might be interested in doing a post-install script or installing it globally.
npm doc for packages installation.

npm install Errors on mac 10.7.5

I am learning mongodb and as part of my learning process, I installed mongodb, nodejs and npm. When I execute the instruction npm install, this is the error I get:
me$ npm install
npm WARN package.json # No repository field.
npm ERR! Darwin 11.4.2
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install"
npm ERR! node v4.2.2
npm ERR! npm v2.14.7
npm ERR! version not found: mongodb#3.2.1
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR! <https://github.com/npm/npm/issues>
npm ERR! Please include the following file with any support request:
npm ERR! /Users/me/Sites/mongodb/chapter1/npm-debug.log
This is the package.json:
{
"scripts": {
"test": "gulp test",
"watch": "gulp watch"
},
"dependencies": {
"async": "0.9.0",
"mongodb": "3.2.1"
},
"devDependencies": {
"gulp": "3.8.11",
"gulp-mocha": "2.0.1",
"mocha": "2.2.4"
}
}
I created a database called mongodb so it can see it but, I don't know what is wrong. I read the npm install errors" but nothing points to the similar error so I can solve it myself. Please, help !!
npm ERR! version not found: mongodb#3.2.1
It means the version 3.2.1 of the mongodb package doesn't exist (see https://www.npmjs.com/package/mongodb - currently, last version in 2.1.4).
Just fix the version number in your package.json from:
"dependencies": {
"async": "0.9.0",
"mongodb": "3.2.1"
},
to
"dependencies": {
"async": "0.9.0",
"mongodb": "^2.1.4"
},
Then re-run npm install

npm package.json bin chmod error

I have created an npm package and I am trying to install it from a git repository. Everything works fine when I run npm install /path/to/package/ --no-bin-links, but I have my package.json set up to link the main JS file into bin. When I try to install the package normally, I get the following error:
npm ERR! path /staging/webshares/proj-test/node_modules/jkvc-project/index.js
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! enoent ENOENT, chmod '/staging/webshares/proj-test/node_modules/jkvc-project/index.js'
npm ERR! enoent This is most likely not a problem with npm itself
npm ERR! enoent and is related to npm not being able to find a file.
The index.js file definitely exists, and everything in my package.json looks normal:
{
"name": "jkvc-project",
"version": "1.0.0",
"description": "JKD Project Build Tool",
"dependencies": {
"bower": "^1.4.1",
"mkdirp": "^0.5.0",
"optimist": "~0.6.0",
"prompt": "~0.2.12",
"q": "~1.0.0",
"request": "~2.33.0"
},
"files": [
"./scss"
],
"bin": "./index.js"
}
I have tried npm cache clean, but it didn't help. I also have a blank .npmignore file in the directory.
Does anyone know what it causing this chmod error, and how to fix it?
This is the folder structure of my package:
scss
.gitignore
.npmignore
index.js
package.json

Resources