I am following this installation guide and got error cannot find module - https://yarnpkg.com/getting-started/install
Here is repo - https://github.com/worldpwn/yarn-3-cannot-find-module-error
Step 1 Install Corepack
$ node -v
v16.13.0
$ corepack enable
Step 2 Initializing your project
$ yarn -v
1.22.15
$ yarn set version stable
➤ YN0000: Retrieving https://repo.yarnpkg.com/3.1.1/packages/yarnpkg-cli/bin/yarn.js
➤ YN0000: Saving the new release in .yarn/releases/yarn-3.1.1.cjs
➤ YN0000: Done in 0s 508ms
$ yarn -v
3.1.1
$ yarn init -2
{
name: 'yarn-3-cannot-find-module-error',
packageManager: 'yarn#3.1.1'
}
Step 3 Install Lodash
$ yarn add lodash
➤ YN0000: ┌ Resolution step
➤ YN0000: └ Completed
➤ YN0000: ┌ Fetch step
➤ YN0013: │ lodash#npm:4.17.21 can't be found in the cache and will be fetched from the remote registry
➤ YN0000: └ Completed
➤ YN0000: ┌ Link step
➤ YN0000: └ Completed
➤ YN0000: Done in 0s 165ms
Step 4 Run hello world
index.js
console.log('hello world')
$ node index.js
hello world
Step 5 Use lodash - ERROR
index.js
var multiply = require('lodash/multiply');
console.log(multiply(3, 5))
$ node index.js
node:internal/modules/cjs/loader:936
throw err;
^
Error: Cannot find module 'lodash/multiply'
Require stack:
- C:\Users\a.kniazev\Documents\GitHub\yarn-3-cannot-find-module-error\index.js
←[90m at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)←[39m
←[90m at Function.Module._load (node:internal/modules/cjs/loader:778:27)←[39m
←[90m at Module.require (node:internal/modules/cjs/loader:1005:19)←[39m
←[90m at require (node:internal/modules/cjs/helpers:102:18)←[39m
at Object.<anonymous> (C:\Users\a.kniazev\Documents\GitHub\yarn-3-cannot-find-module-error\index.js:1:16)
←[90m at Module._compile (node:internal/modules/cjs/loader:1101:14)←[39m
←[90m at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)←[39m
←[90m at Module.load (node:internal/modules/cjs/loader:981:32)←[39m
←[90m at Function.Module._load (node:internal/modules/cjs/loader:822:12)←[39m
←[90m at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)←[39m {
code: ←[32m'MODULE_NOT_FOUND'←[39m,
requireStack: [
←[32m'C:\\Users\\a.kniazev\\Documents\\GitHub\\yarn-3-cannot-find-module-error\\index.js'←[39m
]
}
P.S. npm is working fine in other projects
If i will do npm i:
$ npm i
added 1 package, and audited 2 packages in 934ms
found 0 vulnerabilities
Everything works:
$ node index.js
15
I figure out that the problem is that I have to run index.js using this command:
$ yarn node index.js
15
As I understand it uses PnP to resolve dependencies:
https://yarnpkg.com/features/pnp
https://yarnpkg.com/features/pnp#initializing-pnp
Building on Andrei's answer (this is from https://yarnpkg.com/features/pnp#initializing-pnp):
As a quick tip, all yarn node typically does is set the NODE_OPTIONS environment variable to use the --require option from Node, associated with the path of the .pnp.cjs file. You can easily apply this operation yourself if you prefer:
node -r ./.pnp.cjs ./server.js
NODE_OPTIONS="--require $(pwd)/.pnp.cjs" node ./server.js
Related
When I tried to install near-sdk-as on my laptop (Intel-based macOS 10.13) with the command:
yarn add -D near-sdk-as
I got the following error:
❯ yarn add -D near-sdk-as
yarn add v1.22.17
info No lockfile found.
[1/4] 🔍 Resolving packages...
warning near-sdk-as > near-sdk-core > near-vm > binary-install > axios#0.19.2: Critical security vulnerability fixed in v0.21.1. For more information, see https://github.com/axios/axios/pull/3410
[2/4] 🚚 Fetching packages...
[3/4] 🔗 Linking dependencies...
warning "near-sdk-as > near-sdk-core > #as-pect/cli#6.2.4" has incorrect peer dependency "assemblyscript#^0.19.3".
warning "near-sdk-as > near-sdk-core > #as-pect/cli > #as-pect/assembly#6.2.0" has incorrect peer dependency "assemblyscript#^0.19.3".
warning "near-sdk-as > near-sdk-core > #as-pect/cli > #as-pect/core#6.2.1" has incorrect peer dependency "assemblyscript#^0.19.3".
[4/4] 🔨 Building fresh packages...
error /Users/admin/Develop/Learn-Near/NEAR-101/node_modules/near-vm: Command failed.
Exit code: 1
Command: node ./install.js
Arguments:
Directory: /Users/admin/Develop/Learn-Near/NEAR-101/node_modules/near-vm
Output:
/Users/admin/Develop/Learn-Near/NEAR-101/node_modules/follow-redirects/node_modules/debug/src/debug.js:47
hash = ((hash <
SyntaxError: Unexpected end of input
at Object.compileFunction (node:vm:352:18)
at wrapSafe (node:internal/modules/cjs/loader:1032:15)
at Module._compile (node:internal/modules/cjs/loader:1067:27)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1155:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.<anonymous> (/Users/admin/Develop/Learn-Near/NEAR-101/node_modules/follow-redirects/node_modules/debug/src/node.js:14:28)
at Module._compile (node:internal/modules/cjs/loader:1103:14)
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.
Other info:
npm version: 8.3.1
yarn version: v1.22.17
Any thoughts on how to fix the error and complete the sdk installation?
Thanks!
Try yarn cache clean --force first, then rerun yarn.
Why? You have broken dependency files cached, so you want to clean the cache and download from scratch
I try to install Plotly extension to Jupiterlab. After I installed every package (Anaconda, jupyterlab "ipywidgets>=7.5") I try to install "jupyter labextension install jupyterlab-plotly#4.14.3" but I got an error message: RuntimeError: JupyterLab failed to build
I try to identify the problem from the Log file, but I have no idea what to do next
The log file:
Yarn configuration loaded.
Node v15.12.0
"C:\Users\Szarka Roland\anaconda3\npm.CMD" pack jupyterlab-plotly#4.14.3
npm notice
npm notice package: jupyterlab-plotly#4.14.3
npm notice === Tarball Contents ===
npm notice 156B README.md
npm notice 6.3kB dist/javascript-renderer-extension.js
npm notice 1.0kB package.json
npm notice 545B style/index.css
npm notice 1.0kB style/plotly.svg
npm notice === Tarball Details ===
npm notice name: jupyterlab-plotly
npm notice version: 4.14.3
npm notice filename: jupyterlab-plotly-4.14.3.tgz
npm notice package size: 3.1 kB
npm notice unpacked size: 9.1 kB
npm notice shasum: bb424a50226c2ce1b816f061a8123f0f42418fc0
npm notice integrity: sha512-6ZdmIQ5fDiBTY[...]nASwRNCf1U1Cg==
npm notice total files: 5
npm notice
jupyterlab-plotly-4.14.3.tgz
Yarn configuration loaded.
Node v15.12.0
Building jupyterlab assets (build:prod:minimize)
> node "C:\Users\Szarka Roland\anaconda3\lib\site-packages\jupyterlab\staging\yarn.js" install --non-interactive
yarn install v1.15.2
[1/5] Validating package.json...
[2/5] Resolving packages...
[3/5] Fetching packages...
info fsevents#1.2.11: The platform "win32" is incompatible with this module.
info "fsevents#1.2.11" is an optional dependency and failed compatibility check. Excluding it from installation.
[4/5] Linking dependencies...
warning "jupyterlab-plotly > #lumino/widgets > #lumino/coreutils#1.5.3" has unmet peer dependency "crypto#1.0.1".
[5/5] Building fresh packages...
success Saved lockfile.
Done in 9.81s.
> node "C:\Users\Szarka Roland\anaconda3\lib\site-packages\jupyterlab\staging\yarn.js" yarn-deduplicate -s fewer
yarn run v1.15.2
error Command "yarn-deduplicate" not found.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
> node "C:\Users\Szarka Roland\anaconda3\lib\site-packages\jupyterlab\staging\yarn.js"
yarn install v1.15.2
[1/5] Validating package.json...
[2/5] Resolving packages...
success Already up-to-date.
Done in 0.52s.
> node "C:\Users\Szarka Roland\anaconda3\lib\site-packages\jupyterlab\staging\yarn.js" run build:prod:minimize
yarn run v1.15.2
$ ensure-max-old-space webpack --config webpack.prod.minimize.config.js
node:internal/modules/cjs/loader:352
throw err;
^
Error: Cannot find module 'C:\Users\Szarka Roland\anaconda3\share\jupyter\lab\staging\node_modules\which\which.js'. Please verify that the package.json has a valid "main" entry
at tryPackage (node:internal/modules/cjs/loader:344:19)
at Function.Module._findPath (node:internal/modules/cjs/loader:557:18)
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:910:27)
at Function.Module._load (node:internal/modules/cjs/loader:769:27)
at Module.require (node:internal/modules/cjs/loader:996:19)
at require (node:internal/modules/cjs/helpers:92:18)
at Object.<anonymous> (C:\Users\Szarka Roland\anaconda3\share\jupyter\lab\staging\node_modules\#jupyterlab\buildutils\lib\ensure-max-old-space.js:28:28)
at Module._compile (node:internal/modules/cjs/loader:1092:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1121:10)
at Module.load (node:internal/modules/cjs/loader:972:32) {
code: 'MODULE_NOT_FOUND',
path: 'C:\\Users\\Szarka Roland\\anaconda3\\share\\jupyter\\lab\\staging\\node_modules\\which\\package.json',
requestPath: 'which'
}
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
JupyterLab failed to build
Traceback (most recent call last):
File "C:\Users\Szarka Roland\anaconda3\lib\site-packages\jupyterlab\debuglog.py", line 47, in debug_logging
yield
File "C:\Users\Szarka Roland\anaconda3\lib\site-packages\jupyterlab\labextensions.py", line 105, in start
command=command, app_options=app_options)
File "C:\Users\Szarka Roland\anaconda3\lib\site-packages\jupyterlab\commands.py", line 459, in build
command=command, clean_staging=clean_staging)
File "C:\Users\Szarka Roland\anaconda3\lib\site-packages\jupyterlab\commands.py", line 669, in build
raise RuntimeError(msg)
RuntimeError: JupyterLab failed to build
Exiting application: jupyter
I have tried to create a project using
$ vue init webpack test
and got following error
/usr/local/lib/node_modules/vue-cli/bin/vue-init:60 let template =
program.args[0]
^ SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode at
exports.runInThisContext (vm.js:53:16) at Module._compile
(module.js:374:25) at Object.Module._extensions..js (module.js:417:10)
at Module.load (module.js:344:32) at Function.Module._load
(module.js:301:12) at Function.Module.runMain (module.js:442:10) at
startup (node.js:136:18) at node.js:966:3
Unfortunatly, "test" directory is not created.
I am using Bash on Ubuntu on Windows 10 and the following NPM packages:
vue#2.5.2
vue-cli#2.9.1
node.js#0.0.0
npm 3.5.2
Perhaps node verison is too low.
update your node version using
npm install -g n
sudo n stable
sudo npm install npm -g
when you node -v find there is no change, but try to init vue project again.
I am new to gulp but on a existing laravel project I needed to add some css I was told to update the app.sass and then run gulp to compile it. I tried to follow a guide called Compiling Assets (Laravel Elixir) to compile the sass file but ran into problems. To get everything installed correctly I updated our bootstrap.sh file in the vagrant setup to include nodejs, npm, gulp and laravel-elixir. Once the changes were made I loaded the vagrant box and I verified that I have the following versions.
[vagrant#localhost project-css]$ gulp -v
[18:12:38] CLI version 1.4.0
[18:12:38] Local version 3.9.1
[vagrant#localhost project-css]$ npm -v
3.10.10
[vagrant#localhost project-css]$ node -v
v6.11.1
When I try to run gulp I get
/vagrant/src/project-css/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:349
if (n <= 0 || state.length === 0 && state.end
SyntaxError: Invalid or unexpected token
at createScript (vm.js:56:10)
at Object.runInThisContext (vm.js:97:10)
at Module._compile (module.js:542:28)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/vagrant/src/project-css/node_modules/through2/node_modules/readable-stream/readable.js:12:30)
The full project I'm working on is available on github at Rockefeller-css
Any suggestions would be appreciated.
I was able to resolve the issue on my own by adding the following to my bootstrap.sh file
rpm -ivh https://kojipkgs.fedoraproject.org//packages/http-parser/2.7.1/3.el7/x86_64/http-parser-2.7.1-3.el7.x86_64.rpm
yum install -y nodejs
Also after vagrant was finished loading and I was able to ssh into the box in a custom setup-vagrant.sh script that needed to be ran I was able to add the following command.
sudo npm install
Their was already a cd into the laravel project folder and their was a package.json file that existed. After that I was able to cd into the project folder and run gulp correctly.
Trying to get code running from my groups repo.... everyone elses seems to install and run fine, but my setup is having issues. Not sure if this is a dependency issue or not.
Tried removing node / npm / nvm and reinstalling everything including code from repo. Still having issues...
React : 0.14.8
react-native-cli: 0.2.0
react-native: 0.24.0
also react-native-cli was installed globally
with npm install -g react-native-cli
command after install : react-native run-ios
getting
/node_modules/react-native/Libraries/react-native/react-native.js:121
...require('React'),
^^^
SyntaxError: Unexpected token ...
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:414:25)
at Module._extensions..js (module.js:442:10)
at Object.require.extensions.(anonymous function) as .js
at Module.load (module.js:356:32)
at Function.Module._load (module.js:311:12)
at Module.require (module.js:366:17)
at require (module.js:385:17)
at
node_modules/react-native/node_modules/babel-core/lib/transformation/file/options/option-manager.js:409:22
at Array.map (native)
In npm#3 subDependencies are installed at the same level of your project dependencies (./node_modules). My guess is the project is missing some dependencies to run the packager. If you haven't already done so, updgrade to npm#3 ($ npm install -g npm), delete your node_modules folder, then try again.
$ rm -rf node_modules && npm install