Update / case-closed:
It turns out I had cd'd into the directory of another, older project in my git folder -- which had npm 6.5 in package.json as a dev dependency -- without realizing it.
I'm having an odd experience starting a nextjs projct. I'm running node 16.10.0 and npm 7.24, and I install via:
% npm -v
7.24.0
% node -v
v16.10.0
npx create-next-app#latest --typescript
Yet after I answer the prompts the process fails, creating the following log file, which reports an attempt to install using npm 6.5.0:
0 info it worked if it ends with ok
1 warn npm npm does not support Node.js v16.10.0
2 warn npm You should probably upgrade to a newer version of node as we
3 warn npm can't make any promises that npm will work with this version.
4 warn npm Supported releases of Node.js are the latest release of 6, 8, 9, 10, 11, 12.
5 warn npm You can find the latest version at https://nodejs.org/
6 verbose cli [
6 verbose cli '/Users/MichaelHildebrand/.nvm/versions/node/v16.10.0/bin/node',
6 verbose cli '/Users/MichaelHildebrand/git/functional-chess/node_modules/.bin/npm',
6 verbose cli 'install',
6 verbose cli '--save-exact',
6 verbose cli '--save',
6 verbose cli 'react',
6 verbose cli 'react-dom',
6 verbose cli 'next',
6 verbose cli '#next/font',
6 verbose cli 'typescript',
6 verbose cli '#types/react',
6 verbose cli '#types/node',
6 verbose cli '#types/react-dom',
6 verbose cli 'eslint',
6 verbose cli 'eslint-config-next'
6 verbose cli ]
7 info using npm#6.5.0
8 info using node#v16.10.0
9 verbose npm-session 28b31a53251e88c0
10 silly install loadCurrentTree
11 silly install readLocalPackageData
12 verbose stack TypeError: cb.apply is not a function
12 verbose stack at /Users/MichaelHildebrand/git/functional-chess/node_modules/npm/node_modules/graceful-fs/polyfills.js:285:20
12 verbose stack at FSReqCallback.oncomplete (node:fs:199:5)
13 verbose cwd /Users/MichaelHildebrand/git/functional-chess/chess-master
14 verbose Darwin 21.6.0
15 verbose argv "/Users/MichaelHildebrand/.nvm/versions/node/v16.10.0/bin/node" "/Users/MichaelHildebrand/git/functional-chess/node_modules/.bin/npm" "install" "--save-exact" "--save" "react" "react-dom" "next" "#next/font" "typescript" "#types/react" "#types/node" "#types/react-dom" "eslint" "eslint-config-next"
16 verbose node v16.10.0
17 verbose npm v6.5.0
18 error cb.apply is not a function
19 verbose exit [ 1, true ]
Why would the install via npx be attempting to use npm 6 when I clearly am at 7 in my terminal?
Can anyone explain how I could get this result, and how to fix?
Looks like you're using MacOs. You probably have an older version of Node/NPM installed in another directory in your PATH. Type the command which npx and which npm to see if they are in different directories. When attempting to run a command with an ambiguous path, the system will try all your path locations in order and execute the first match.
Related
I've received the following in the debug log. I'm looking to npx create-react-app. The terminal is returning
npm ERR! cb.apply is not a function
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\User\AppData\Roaming\npm-cache_logs\2022-06-07T14_57_21_064Z-debug.log
Install for [ 'create-react-app#latest' ] failed with code 1
This is the debug file...
0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli 'C:\\Program Files (x86)\\Nodist\\v-x64\\18.1.0\\node.exe',
1 verbose cli 'C:\\Program Files (x86)\\Nodist\\bin\\node_modules\\npx\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli 'install',
1 verbose cli 'create-react-app#latest',
1 verbose cli '--global',
1 verbose cli '--prefix',
1 verbose cli 'C:\\Users\\User\\AppData\\Roaming\\npm-cache\\_npx\\50292',
1 verbose cli '--loglevel',
1 verbose cli 'error',
1 verbose cli '--json'
1 verbose cli ]
2 info using npm#5.1.0
3 info using node#v18.1.0
4 verbose npm-session 56a59e1a77678c6d
5 silly install loadCurrentTree
6 silly install readGlobalPackageData
7 http fetch GET 200 https://registry.npmjs.org/create-react-app 102ms (from cache)
8 silly pacote tag manifest for create-react-app#latest fetched in 165ms
9 verbose stack TypeError: cb.apply is not a function
9 verbose stack at C:\Program Files (x86)\Nodist\bin\node_modules\npx\node_modules\npm\node_modules\graceful-fs\polyfills.js:287:18
9 verbose stack at FSReqCallback.oncomplete (node:fs:204:5)
10 verbose cwd C:\Users\User\Websites\react
11 verbose Windows_NT 10.0.19044
12 verbose argv "C:\\Program Files (x86)\\Nodist\\v-x64\\18.1.0\\node.exe" "C:\\Program Files (x86)\\Nodist\\bin\\node_modules\\npx\\node_modules\\npm\\bin\\npm-cli.js" "install" "create-react-app#latest" "--global" "--prefix" "C:\\Users\\User\\AppData\\Roaming\\npm-cache\\_npx\\50292" "--loglevel" "error" "--json"
13 verbose node v18.1.0
14 verbose npm v5.1.0
15 error cb.apply is not a function
16 verbose exit [ 1, true ]
I'm using the latest beta version of Node, so I'll try to go back to the latest stable version. If that doesn't work, I'll try to re-download node away from nodist..
If you have any other thoughts or suggestions Perhaps there is a hint in the debug log, then I'd be glad to hear them.
According to the discussion under github https://github.com/facebook/create-react-app/discussions/10173#discussioncomment-142156
you need to
npm rm -g create-react-app
npm install create-react-app
npx create-react-app my-app
After deleting the Nodist version manager. I installed nvm and I'm now able to get npx to work without a problem. I think the issue for me was that I was using the nodist version manager.
Highly recommend checking out nvm here if you get similar issues.
https://github.com/coreybutler/nvm-windows/wiki
I am trying to get my project started but I got this error.
Error from Terminal
The environment requires npm 6.x or lower. I checked with Terminal and it does satisfy the required version.
my npm version
I had once installed node v16 using the official installer before but soon I uninstalled it by following the steps I googled (like sudo rm all node-related stuff).
What I had done includes the following:
Clear Cache, Remove package-lock.json, Remove node_modules, and reinstall - not working
rm all the node-related files and reinstall node (v14) - not working
use nvm to run - not working
Here is the debug log I got from npm:
0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli '/Users/.nvm/versions/node/v12.22.12/bin/node',
1 verbose cli '/Users/.nvm/versions/node/v12.22.12/bin/npm',
1 verbose cli 'run',
1 verbose cli 'start'
1 verbose cli ]
2 info using npm#6.14.16
3 info using node#v12.22.12
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info lifecycle sentry_fe#1.0.0~prestart: sentry_fe#1.0.0
6 info lifecycle sentry_fe#1.0.0~start: sentry_fe#1.0.0
7 verbose lifecycle sentry_fe#1.0.0~start: unsafe-perm in lifecycle true
8 verbose lifecycle sentry_fe#1.0.0~start: PATH: /Users/.nvm/versions/node/v12.22.12/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/Users/Documents/WORK/governance-sentry-fe/node_modules/.bin:/Users/.nvm/versions/node/v12.22.12/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/puppetlabs/bin:/Applications/Visual Studio Code.app/Contents/Resources/app/bin:/Applications/Visual Studio Code.app/Contents/Resources/app/bin
9 verbose lifecycle sentry_fe#1.0.0~start: CWD: /Users/Documents/WORK/governance-sentry-fe
10 silly lifecycle sentry_fe#1.0.0~start: Args: [ '-c', 'eden start' ]
11 silly lifecycle sentry_fe#1.0.0~start: Returned: code: 1 signal: null
12 info lifecycle sentry_fe#1.0.0~start: Failed to exec start script
13 verbose stack Error: sentry_fe#1.0.0 start: `eden start`
13 verbose stack Exit status 1
13 verbose stack at EventEmitter.<anonymous> (/Users/.nvm/versions/node/v12.22.12/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:332:16)
13 verbose stack at EventEmitter.emit (events.js:314:20)
13 verbose stack at ChildProcess.<anonymous> (/Users/.nvm/versions/node/v12.22.12/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack at ChildProcess.emit (events.js:314:20)
13 verbose stack at maybeClose (internal/child_process.js:1022:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:287:5)
14 verbose pkgid sentry_fe#1.0.0
15 verbose cwd /Users/Documents/WORK/governance-sentry-fe
16 verbose Darwin 21.3.0
17 verbose argv "/Users/.nvm/versions/node/v12.22.12/bin/node" "/Users/.nvm/versions/node/v12.22.12/bin/npm" "run" "start"
18 verbose node v12.22.12
19 verbose npm v6.14.16
20 error code ELIFECYCLE
21 error errno 1
22 error sentry_fe#1.0.0 start: `eden start`
22 error Exit status 1
23 error Failed at the sentry_fe#1.0.0 start script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]
Would any one imply other methods that I can use? Any responses would be appreciated.
I'm not sure if I understand your question, but I'll try my best to answer.
You can reinstall the latest version of Node.js from the official website (it should remove the old version).
This should also install npm at version 8.
To downgrade npm, you need to run the following command.
$ npm install -g npm#6.14.16
This should leave Node.js at the highest version, and npm at your desired version.
install n;
npm install -g n
or without node on mac;
brew install n
after installation execute;
n 16.15.1
if you want other versions;
n <version>
or you can install last via;
n latest
i advise for new developers;
n lts
also you can switch installed versions via
n
For more info...
I have installed ReactJS to work on some project but this mistakes are making me sick.
First error appear when I tried to add package for my project.
So , I used :
yarn add #material-ui/icons
and after that It was fetching.
And I got this error message on the terminal line :
error An unexpected error occurred: "EPERM: operation not permitted, unlink 'C:\\React\\MyProject\\node_modules\\node-sass\\vendor\\win32-x64-93\\bindiinfo Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.
I found some solutions and wanted to try. Whenever I try to use install command, it does not let me.
It gives this error
npm ERR! cb.apply is not a function
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\XXXXXX\AppData\Roaming\npm-cache\_logs\2021-11-14T00_08_12_781Z-debug.log
enter code here
and whenever I click this error log, here is what I see.
0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli 'C:\\Users\\XXXXXXXX\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli 'install',
1 verbose cli '-g',
1 verbose cli 'yarn'
1 verbose cli ]
2 info using npm#5.3.0
3 info using node#v16.13.0
4 verbose npm-session 95556b4f7a104717
5 silly install loadCurrentTree
6 silly install readGlobalPackageData
7 http fetch GET 200 https://registry.npmjs.org/yarn 188ms
8 http fetch GET 200 https://registry.npmjs.org/yarn/-/yarn-1.22.17.tgz 120ms
9 silly pacote tag manifest for yarn#latest fetched in 352ms
10 verbose stack TypeError: cb.apply is not a function
10 verbose stack at C:\Users\XXXXXXX\AppData\Roaming\npm\node_modules\npm\node_modules\graceful-fs\polyfills.js:287:18
10 verbose stack at FSReqCallback.oncomplete (node:fs:199:5)
11 verbose cwd D:\React\projem
12 verbose Windows_NT 10.0.19043
13 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\XXXXXXXX\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "install" "-g" "yarn"
14 verbose node v16.13.0
15 verbose npm v5.3.0
16 error cb.apply is not a function
17 verbose exit [ 1, true ]
Please help me or I'll drive crazy so soon!
All the best everyone and THANK YOU! for your help.
Please stop the development server and install or add the packages.
I faced same issue when I tried to install the blueprint package using yarn, I solved it by using npm package manager (npm install)
I'm trying to install next js with command below:
$c:/Desktop/next: npm init next-app nextjs-blog
Which gave me an error
npm ERR! Could not install from "Dahal\AppData\Roaming\npm-cache\_npx\14636" as it does not contain a package.json file.
Note: My Users is C:/Users/Sunita Dahal but it seems to be looking inside of Dahal. But I'm able to install global packages.
reinstalling & cleaning cache doesnt work work me
Here is the complete error log:
0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli 'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli 'install',
1 verbose cli 'create-next-app#latest',
1 verbose cli '--global',
1 verbose cli '--prefix',
1 verbose cli 'C:\\Users\\Sunita',
1 verbose cli 'Dahal\\AppData\\Roaming\\npm-cache\\_npx\\14636',
1 verbose cli '--loglevel',
1 verbose cli 'error',
1 verbose cli '--json'
1 verbose cli ]
2 info using npm#6.14.4
3 info using node#v12.16.3
4 verbose npm-session a7314bdab23f336e
5 silly install loadCurrentTree
6 silly install readGlobalPackageData
7 silly fetchPackageMetaData error for file:Dahal\AppData\Roaming\npm-cache\_npx\14636 Could not install from "Dahal\AppData\Roaming\npm-cache\_npx\14636" as it does not contain a package.json file.
8 http fetch GET 304 https://registry.npmjs.org/create-next-app 167ms (from cache)
9 silly pacote tag manifest for create-next-app#latest fetched in 190ms
10 timing stage:rollbackFailedOptional Completed in 1ms
11 timing stage:runTopLevelLifecycles Completed in 204ms
12 verbose stack Error: ENOENT: no such file or directory, open 'C:\Users\Sunita Dahal\Desktop\next\Dahal\AppData\Roaming\npm-cache\_npx\14636\package.json'
13 verbose cwd C:\Users\Sunita Dahal\Desktop\next
14 verbose Windows_NT 10.0.18362
15 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "create-next-app#latest" "--global" "--prefix" "C:\\Users\\Sunita" "Dahal\\AppData\\Roaming\\npm-cache\\_npx\\14636" "--loglevel" "error" "--json"
16 verbose node v12.16.3
17 verbose npm v6.14.4
18 error code ENOLOCAL
19 error Could not install from "Dahal\AppData\Roaming\npm-cache\_npx\14636" as it does not contain a package.json file.
20 verbose exit [ 1, true ]
SOLUTION
Changing my cache path fixed the issue for me.
npm config set cache C:\tmp\nodejs\npm-cache --global
more at: https://github.com/zkat/npx/issues/146
So the command npm init will initialize a new project and generate a package.json file that contains project-related information. The command can be run anywhere. Use npm init when you want to create a new project of your own.
However, npm install, or npm i for short, will install project-related dependencies in the package.json file in an existing project directory. You can also use npm i package_name_here to install new package to your current project. The command must be run in an existing project directory with a valid package.json
I use the n version manager and when I change the Node version to 11.10 NPM stops working.
$ n latest
node/11.10.1
$ npm i sinon
npm ERR! Cannot read property 'resolve' of undefined
npm ERR! A complete log of this run can be found in:
npm ERR! /home/myuser/.npm/_logs/2019-03-04T22_12_54_458Z-debug.log
$ npm --version
6.7.0
If I change back to the previous version of Node - or any earlier version really, it starts working again.
The full output from the debug log
0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node', '/usr/local/bin/npm', 'i', 'sinon' ]
2 info using npm#6.7.0
3 info using node#v11.10.1
4 verbose npm-session d32761bbecba8a12
5 silly install loadCurrentTree
6 silly install readLocalPackageData
7 silly fetchPackageMetaData error for sinon#^7.2.7 Cannot read property 'resolve' of undefined
8 timing stage:rollbackFailedOptional Completed in 0ms
9 timing stage:runTopLevelLifecycles Completed in 73ms
10 verbose stack TypeError: Cannot read property 'resolve' of undefined
10 verbose stack at regFetch (/usr/local/lib/node_modules/npm/node_modules/npm-registry-fetch/index.js:76:23)
10 verbose stack at fetchPackument (/usr/local/lib/node_modules/npm/node_modules/pacote/lib/fetchers/registry/packument.js:42:10)
10 verbose stack at packument (/usr/local/lib/node_modules/npm/node_modules/pacote/lib/fetchers/registry/packument.js:20:10)
10 verbose stack at getManifest (/usr/local/lib/node_modules/npm/node_modules/pacote/lib/fetchers/registry/manifest.js:22:10)
10 verbose stack at manifest (/usr/local/lib/node_modules/npm/node_modules/pacote/lib/fetchers/registry/manifest.js:13:10)
10 verbose stack at Object.manifest (/usr/local/lib/node_modules/npm/node_modules/pacote/lib/fetchers/registry/index.js:17:12)
10 verbose stack at Object.Fetcher#manifest [as manifest] (/usr/local/lib/node_modules/npm/node_modules/genfun/lib/genfun.js:15:38)
10 verbose stack at manifest (/usr/local/lib/node_modules/npm/node_modules/pacote/lib/fetch.js:23:18)
10 verbose stack at pinflight (/usr/local/lib/node_modules/npm/node_modules/pacote/manifest.js:24:12)
10 verbose stack at /usr/local/lib/node_modules/npm/node_modules/promise-inflight/inflight.js:29:24
10 verbose stack at Promise._execute (/usr/local/lib/node_modules/npm/node_modules/bluebird/js/release/debuggability.js:313:9)
10 verbose stack at Promise._resolveFromExecutor (/usr/local/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:483:18)
10 verbose stack at new Promise (/usr/local/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:79:10)
10 verbose stack at _inflight (/usr/local/lib/node_modules/npm/node_modules/promise-inflight/inflight.js:28:25)
10 verbose stack at /usr/local/lib/node_modules/npm/node_modules/promise-inflight/inflight.js:22:14
10 verbose stack at tryCatcher (/usr/local/lib/node_modules/npm/node_modules/bluebird/js/release/util.js:16:23)
11 verbose cwd /tmp/foo
12 verbose Linux 4.15.0-34-generic
13 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "i" "sinon"
14 verbose node v11.10.1
15 verbose npm v6.7.0
16 error Cannot read property 'resolve' of undefined
17 verbose exit [ 1, true ]
This seems to be a problem with n, or how it bundles NPM, for (only) version 11.10 of Node. Basically the global npm install is broken.
This is resolved if one uses n to revert to an earlier version of Node and NPM and downloads the same problematic release (6.7.0).
n 11.9
npm install -g npm#6.7
n 11.10
This seems to overwrite the existing cached, global download of NPM version 6.7.0 and fix the install. The fix persists to work, even after switching between Node versions, even though the npm command is reset to point to the default each time. This means that even if you do npm i npm#6.8 -g to do a global upgrade of npm it will be reset to 6.7 the next time you switch back and forth to Node 11.10.
Are you running a version of n older than v2.1.12? n was updated in v2.1.12 to remove the previous npm node_modules folder during installation, to avoid problems when layout and content of the npm modules folder changes between versions.
If you have installed n using npm then, short version:
npm install -g n
Long version:
https://github.com/tj/n/issues/508#issuecomment-423933394
https://stackoverflow.com/a/53985680/1082434